-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
4,481 additions
and
863 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
. bin/vars.sh | ||
|
||
js=(${CLIENT_PROJECTS} ${JS_LIBS}) | ||
|
||
for a in "${js[@]}"; do | ||
echo " $a:" | ||
|
||
(cd "$a" && grep -q "\"translate\":" package.json && pnpm translate) | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,9 @@ | ||
import i18n, {ResourceLanguage} from 'i18next'; | ||
import {initReactI18next} from 'react-i18next'; | ||
import LanguageDetector from 'i18next-browser-languagedetector'; | ||
import {defaultLocale, locales} from './lib/locales'; | ||
import * as appLangs from './locales/app'; | ||
import {createI18N, createNS} from '@alchemy/i18n'; | ||
import * as appLangs from '../translations'; | ||
|
||
const resources: {[language: string]: ResourceLanguage} = {}; | ||
|
||
function addNS(ns: string, r: {[language: string]: ResourceLanguage}): void { | ||
locales.forEach(l => { | ||
if (!resources[l]) { | ||
resources[l] = {[ns]: r[l]}; | ||
} else { | ||
resources[l][ns] = r[l]; | ||
} | ||
}); | ||
} | ||
|
||
addNS('app', appLangs); | ||
|
||
i18n.use(LanguageDetector) | ||
.use(initReactI18next) | ||
.init({ | ||
defaultNS: 'app', | ||
supportedLngs: locales, | ||
fallbackLng: defaultLocale, | ||
interpolation: { | ||
escapeValue: false, // not needed for react as it escapes by default | ||
}, | ||
resources, | ||
}); | ||
|
||
function normalizeHTMLLocale(l: string): string { | ||
return l.replace(/_/g, '-'); | ||
} | ||
|
||
function setHtmlLangAttr(l: string): void { | ||
document.documentElement.setAttribute('lang', normalizeHTMLLocale(l)); | ||
} | ||
|
||
function languageChanged(lng: string): void { | ||
setHtmlLangAttr(lng); | ||
} | ||
|
||
languageChanged(i18n.language); | ||
i18n.on('languageChanged', languageChanged); | ||
console.log('appLangs', appLangs); | ||
const i18n = createI18N({ | ||
resources: createNS(appLangs), | ||
}); | ||
|
||
export default i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
import en_US from './en_US/app.json'; | ||
import fr_FR from './fr_FR/app.json'; | ||
import en from './en/app.json'; | ||
import fr from './fr/app.json'; | ||
import enApi from '@alchemy/api/translations/en.json'; | ||
import frApi from '@alchemy/api/translations/fr.json'; | ||
import enNav from '@alchemy/navigation/translations/en.json'; | ||
import frNav from '@alchemy/navigation/translations/fr.json'; | ||
|
||
export {en_US, fr_FR}; | ||
const enMerged = { | ||
...en, | ||
lib: { | ||
...enApi.lib, | ||
...enNav.lib, | ||
}, | ||
}; | ||
|
||
const frMerged = { | ||
...fr, | ||
lib: { | ||
...frApi.lib, | ||
...frNav.lib, | ||
}, | ||
}; | ||
|
||
export {enMerged as en, frMerged as fr}; |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
databox/client/src/locales/fr_FR/app.json → databox/client/src/locales/fr/app.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.