Skip to content

Instantly share code, notes, and snippets.

View honzabilek4's full-sized avatar
🌱
Working on Localazy

Jan Bílek honzabilek4

🌱
Working on Localazy
View GitHub Profile
@honzabilek4
honzabilek4 / semantic-commits.txt
Last active July 22, 2024 14:12
Semantic commits
https://www.conventionalcommits.org/en/v1.0.0/
feat: add hat wobble
^--^ ^------------^
| |
| +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.
import {
i18n,
initI18n,
getLanguages,
getCurrentLanguage,
getKeyPlural as p,
} from "./i18n";
let count = 0;
const createLanguageSelector = () => {
let template = '<select id="selector">';
import { i18n, initI18n, getLanguages, getCurrentLanguage, getKeyPlural as p } from "./i18n";
let count = 0;
//…
const getTranslatedContent = () => {
 return `${i18n.t("hello_localazy")}<br><br>
 ${count} ${i18n.t(p("calendar", count))}<br>
 ${count} ${i18n.t(p("field", count))}<br>
 ${count} ${i18n.t(p("event", count))}<br>
 ${count} ${i18n.t(p("title", count))}<br>
 ${count} ${i18n.t(p("color", count))}`;
//…
export const getKeyPlural = (key, count) => { 
 const currentLanguage = LocalazyMeta.languages.find(l => l.language === i18next.language);
 const pluralType = currentLanguage.pluralType(+count);
 return `${key}.${pluralType}`;
}
//…
{
"upload": {
"type": "json",
"features": [
"plural_object"
],
"files": "src/locales/en.json"
},
"download": {
"files": "src/locales/${lang}.json",
{
"hello_localazy": "Hello Localazy!",
"calendar": {
"one": "Calendar",
"other": "Calendars"
},
"field": {
"one": "Field",
"other": "Fields"
},
#selector {
 width: 150px;
}
#content {
 margin-top: 1rem;
}
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>`;
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 = () => {
{
"download": {
"files": "src/locales/${lang}.json",
"metadataFileJs": "src/localazy-meta.js"
}
}