Skip to content

Instantly share code, notes, and snippets.

View AlexMost's full-sized avatar

Alexander AlexMost

View GitHub Profile
function minMaxIdx(arr) {
let max = arr[0]
let maxIdx = 0;
let min = arr[0];
let minIdx = 0;
for(let i = 0; i< arr.length; i++) {
if (arr[i] < min) {
min = arr[i];
minIdx = i;
import { addLocale, useLocale } from 'ttag';
const locale = getLocale(); // fetch locale code from cookies, url, localStorage e.t.c
if (locale !== 'en') {
// load json file with translations
const translationsObj = require(`../i18n/${locale}.po.json`);
addLocale(locale, translationsObj);
useLocale(locale);
}
This file has been truncated, but you can view the full file.
> webpack-inspect@0.0.2 build /Users/alexandermostovenko/git/webpack-deps-inspect
> webpack --mode development "--profile" "--json"
Skipping static resource "/Users/alexandermostovenko/git/webpack-deps-inspect/dist/ModulesGraph.608555813bb86bd0463f.js" (4.89 MB) - max size is 2.1 MB
Skipping static resource "/Users/alexandermostovenko/git/webpack-deps-inspect/dist/main.d291962e3b23afd704a1.js" (3.66 MB) - max size is 2.1 MB
Total precache size is about 1.27 MB for 7 resources.
{
"errors": [],
"warnings": [],
import { addLocale, useLocale } from 'c-3po';
const locale = process.env.LOCALE;
let localeTranslations;
if (locale === 'uk') {
localeTranslations = require('./uk.po');
}
// ... other locales if's
import { t, addLocale, useLocale } from 'c-3po';
import gettextParser from 'gettext-parser';
import fs from 'fs';
const locale = process.env.LOCALE; // let's desice that locale is passed through ENV
if (locale) {
// parsing po file with gettext-parser and applying translations
const translationObj = gettextParser.po.parse(
fs.readFileSync(`${locale}.po`).toString()
import { t } from 'c-3po'
const name = 'c-3po';
t`Hello ${ name }`
import { c, t } from 'c-3po'
// The same string can have different translations
t`Hello ${ name }`
c('context')
.t`Hello ${ name }`
import { ngettext, msgid } from 'c-3po';
const n = 5;
ngettext(msgid`${ n } banana`, `${ n } bananas`, n);
import { t } from 'c-3po'
const name = 'c-3po';
t`Hello ${ name }` // translator will see "Hello ${ name }" in .po file
// var a = 5;
// {
// let a = 7;
// console.log(`scoped ${a}`)
// }
// function test() {
// console.log(a);
// }