-
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
97 changed files
with
4,815 additions
and
1,327 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,8 @@ | ||
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); | ||
const i18n = createI18N({ | ||
resources: createNS(appLangs), | ||
}); | ||
|
||
export default i18n; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.