<commit_before>﻿import * as React from 'react'
import { Route } from 'react-router'
import { ajaxPost, ajaxGet } from '../../../Framework/Signum.React/Scripts/Services';
import { EntitySettings } from '../../../Framework/Signum.React/Scripts/Navigator'
import { Entity, Lite } from '../../../Framework/Signum.React/Scripts/Signum.Entities'
import * as Navigator from '../../../Framework/Signum.React/Scripts/Navigator'
import { EntityOperationSettings } from '../../../Framework/Signum.React/Scripts/Operations'
import * as Operations from '../../../Framework/Signum.React/Scripts/Operations'
import { CultureInfoEntity } from '../Basics/Signum.Entities.Basics'


export let currentCulture: CultureInfoEntity;

export function loadCurrentCulture() : Promise<void> {
    return API.fetchCurrentCulture()
        .then(ci => { currentCulture = ci; }); 
}

export const onCultureChanged: Array<(culture: CultureInfoEntity) => void> = [];
export function changeCurrentCulture(newCulture: Lite<CultureInfoEntity>) {
    API.setCurrentCulture(newCulture)
        .then(() => API.fetchCurrentCulture())
        .then(ci => {
            currentCulture = ci;
            onCultureChanged.forEach(f => f(ci));
        }).done();
}

export module API {
    export function fetchCultures(): Promise<{ [name: string]: Lite<CultureInfoEntity> }> {
        return ajaxGet<{ [name: string]: Lite<CultureInfoEntity> }>({ url: "~/api/translation/cultures", cache: "no-cache" });
    }

    export function fetchCurrentCulture(): Promise<CultureInfoEntity> {
        return ajaxGet<CultureInfoEntity>({ url: "~/api/translation/currentCulture", cache: "no-cache" });
    }

    export function setCurrentCulture(culture: Lite<CultureInfoEntity>): Promise<void> {<commit_msg>fix CultureClient<commit_after>﻿import * as React from 'react'
import { Route } from 'react-router'
import { ajaxPost, ajaxGet } from '../../../Framework/Signum.React/Scripts/Services';
import { EntitySettings } from '../../../Framework/Signum.React/Scripts/Navigator'
import { Entity, Lite } from '../../../Framework/Signum.React/Scripts/Signum.Entities'
import * as Navigator from '../../../Framework/Signum.React/Scripts/Navigator'
import { EntityOperationSettings } from '../../../Framework/Signum.React/Scripts/Operations'
import * as Operations from '../../../Framework/Signum.React/Scripts/Operations'
import { CultureInfoEntity } from '../Basics/Signum.Entities.Basics'


export let currentCulture: CultureInfoEntity;


export const onCultureLoaded: Array<(culture: CultureInfoEntity) => void> = [];
export function loadCurrentCulture() : Promise<void> {
    return API.fetchCurrentCulture()
        .then(ci => {
            currentCulture = ci;
            onCultureLoaded.forEach(f => f(ci));
        }); 
}

export function changeCurrentCulture(newCulture: Lite<CultureInfoEntity>) {
    API.setCurrentCulture(newCulture)
        .then(() => loadCurrentCulture())
        .done();
}

export module API {
    export function fetchCultures(): Promise<{ [name: string]: Lite<CultureInfoEntity> }> {
        return ajaxGet<{ [name: string]: Lite<CultureInfoEntity> }>({ url: "~/api/translation/cultures", cache: "no-cache" });
    }

    export function fetchCurrentCulture(): Promise<CultureInfoEntity> {
        return ajaxGet<CultureInfoEntity>({ url: "~/api/translation/currentCulture", cache: "no-cache" });
    }

    export function setCurrentCulture(culture: Lite<CultureInfoEntity>): Promise<void> {
{'fraction_non_alphanumeric': 0.1578795736099107, 'fraction_numerical': 0.0, 'mean_word_length': 3.8832630098452885, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3866076', 'n_tokens_mistral': 979, 'n_tokens_neox': 985, 'n_words': 212}