Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function addTranslationsToTTag(translations: Translations[]) {
const localesToUse: Locale[] = [];
// register with ttag
for (const t of translations) {
const locale = localeFromString(t.headers.language);
addLocale(locale.string, t);
localesToUse.push(locale);
}
console.log('Available locales:', localesToUse.map(l => l.string));
// set locale in ttag
useLocales(localesToUse.map(locale => locale.string));
// update active locales
// we need to modify the actual array content, so that all imported references get the changes
currentLocales.splice(0, currentLocales.length);
currentLocales.push(...localesToUse);
}
function loadAllLocales() {
fs.readdirSync(poDirPath)
.forEach(poFileName => {
const localeToLoad = path.basename(poFileName, '.txt');
loadedLocales.push(localeToLoad);
const poFileContent = fs.readFileSync(path.join(poDirPath, poFileName));
loadLocalizationFromPOFile(localeToLoad, poFileContent);
});
}
loadAllLocales();
const preferredLocales = uniq([
loadedLocales.indexOf(locale) === -1 ? localeWithoutCountry(locale) : locale,
'en_US'
]);
useLocales(preferredLocales);
const selectors = {
homeButton: t`Home`,
startButton: t`Okay, let’s go!`,
placeMarker: 'Bunte SchokoWelt' + ' ' + t`Fully wheelchair accessible`,
editButton: t`Fully wheelchair accessible` + ' ' + t`Entrance has no steps, and all rooms are accessible without steps.`,
expandButton: t`Expand details`,
partiallyOption: t`Partially`,
cancelButton: t`Cancel`,
addImagesButton: t`Add images`,
searchButton: t`Search`,
searchInput: t`Search for place or address`,
shoppingButton: t`Shopping`,
atLeastPartiallyWheelchairAccessibleButton: t`Partially wheelchair accessible`,
goButton: t`Go!`,
showMeWhereIAmButton: t`Show me where I am`,