This file contains hidden or 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
import { i18n, initI18n } from "./i18n"; | |
const createPageContent = () => { | |
document.querySelector("#app").innerHTML = i18n.t("hello_localazy"); | |
} | |
initI18n(createPageContent); |
This file contains hidden or 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
{ | |
"writeKey": "<your-write-key>", | |
"readKey": "<your-read-key>", | |
"upload": { | |
"type": "json", | |
"files": "src/locales/en.json" | |
}, | |
"download": { | |
"files": "src/locales/${lang}.json" | |
} |
This file contains hidden or 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
{ | |
"scripts": { | |
"start": "parcel index.html - open", | |
"build": "parcel build index.html", | |
"upload": "localazy upload", | |
"download": "localazy download", | |
"list": "localazy list" | |
} | |
} |
This file contains hidden or 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
import i18next from "i18next"; | |
import enJson from "./locales/en.json"; | |
import frJson from "./locales/fr.json"; | |
import csJson from "./locales/cs.json"; | |
export const i18n = i18next; | |
export const initI18n = (callback) => { | |
i18next.init( | |
{ | |
lng: "en", | |
debug: true, |
This file contains hidden or 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
{ | |
"download": { | |
"files": "src/locales/${lang}.json", | |
"metadataFileJs": "src/localazy-meta.js" | |
} | |
} |
This file contains hidden or 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
import i18next from "i18next"; | |
import LocalazyMeta from "./localazy-meta"; | |
import enJson from "./locales/en.json"; | |
import frJson from "./locales/fr.json"; | |
import csJson from "./locales/cs.json"; | |
export const i18n = i18next; | |
export const getSupportedLangCodes = () => { | |
return LocalazyMeta.languages.map((l) => l.language); | |
}; | |
export const getBaseLanguage = () => { |
This file contains hidden or 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
import { i18n, initI18n, getLanguages, getCurrentLanguage } from "./i18n"; | |
const createLanguageSelector = () => { | |
let template = '<select id="selector">'; | |
getLanguages().forEach((l) => { | |
template += ` | |
<option ${l.language === getCurrentLanguage() ? "selected" : ""} value="${ | |
l.language | |
}"> | |
${l.localizedName} | |
</option>`; |
This file contains hidden or 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
#selector { | |
width: 150px; | |
} | |
#content { | |
margin-top: 1rem; | |
} |
This file contains hidden or 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
{ | |
"hello_localazy": "Hello Localazy!", | |
"calendar": { | |
"one": "Calendar", | |
"other": "Calendars" | |
}, | |
"field": { | |
"one": "Field", | |
"other": "Fields" | |
}, |
This file contains hidden or 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
{ | |
"upload": { | |
"type": "json", | |
"features": [ | |
"plural_object" | |
], | |
"files": "src/locales/en.json" | |
}, | |
"download": { | |
"files": "src/locales/${lang}.json", |