Skip to content

Commit

Permalink
translate exports to default language
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethbruskiewicz committed Dec 8, 2023
1 parent e6eb3d8 commit 1a502ae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 644 deletions.
10 changes: 10 additions & 0 deletions lib/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ class Toolbar {

// File -> Export to...
$('#export-to-confirm-btn').click(() => {

const current_language = i18next.language;
i18next.changeLanguage('default')
$(document).localize();

const baseName = $('#base-name-export-to-input').val();
const exportFormat = $('#export-to-format-select').val();
if (!exportFormat) {
Expand All @@ -204,6 +209,10 @@ class Toolbar {
baseName,
format.fileType,
]);

i18next.changeLanguage(current_language)
$(document).localize(current_language);

}
$('#export-to-modal').modal('hide');
});
Expand Down Expand Up @@ -368,6 +377,7 @@ class Toolbar {
[schema_name, template_name] = template_path.split('/');
schema = await this.getSchema(schema_name, template_name);
exportFormats = await this.getExportFormats(schema_name, template_name);

languages = await this.getLanguages(schema_name); // TODO

// language localization controls
Expand Down
93 changes: 1 addition & 92 deletions lib/utils/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,7 @@ import tags from 'language-tags';
import { flattenObject } from '@/lib/utils/objects';
import label_translations_file from '@/web/translations/translations.json';
import { formatMultivaluedValue } from '@/lib/utils/fields';
// TODO: refactor to a package or list of codes
// TODO: map to what's supported for the template?
export const languages = {
en: {
nativeName: tags.language('en').data.record.Description[0],
langcode: 'en',
},
fr: {
nativeName: tags.language('fr').data.record.Description[0],
langcode: 'fr',
},
};

console.log(i18next)
export const labels = transformStructFirstSpec(label_translations_file);

// TODO: refactor `with*` to JQ
Expand Down Expand Up @@ -159,83 +147,4 @@ function transformStructFirstSpec(obj) {
return result;
}

// TODO: test
// transformLangFirstSpec(source);

// An example object input:
// const inObj = {
// fr: {
// nav: {
// header: {
// greeting: 'bonjour',
// },
// },
// },
// en: {
// nav: {
// header: {
// greeting: 'hello',
// },
// },
// },
// };

// An example object output:
// const outObj = {
// nav: {
// header: {
// greeting: {
// en: 'hello',
// fr: 'bonjour',
// },
// },
// },
// };

// expect the structure-first style

// export const sample_labels = {
// en: {
// head: {
// title: 'My Awesome Landing-Page',
// description: 'The description of this awesome landing page.',
// },
// fr: {
// case_id: 'le case identifique',
// },
// de: {
// head: {
// title: 'Meine grossartige Webseite',
// description: 'Die Beschreibung dieser grossartigen Webseite.',
// },
// intro: {
// title: 'Webseite',
// subTitle: 'Ein Untertitel',
// },
// },
// },
// };

// export const resources = {
// en: {
// translation: {
// third_party_lab_service_provider_name:
// 'Third Party Lab Service Provider Name',
// case_ID: 'Case ID', // English translation for case_id
// // ... other English translations,
// },
// },
// fr: {
// translation: {
// third_party_lab_service_provider_name:
// 'Nom du fournisseur de services de laboratoire tiers',
// case_ID: 'ID du cas',

// // ... other French translations
// GENEPIO_0001128_0: "n'applicable-pas",
// },
// },
// // ... other languages
// };

export { transformLangFirstSpec, transformStructFirstSpec };
Loading

0 comments on commit 1a502ae

Please sign in to comment.