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
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; |
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
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.
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
> 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": [], |
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
import { addLocale, useLocale } from 'c-3po'; | |
const locale = process.env.LOCALE; | |
let localeTranslations; | |
if (locale === 'uk') { | |
localeTranslations = require('./uk.po'); | |
} | |
// ... other locales if's |
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
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() |
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
import { t } from 'c-3po' | |
const name = 'c-3po'; | |
t`Hello ${ name }` |
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
import { c, t } from 'c-3po' | |
// The same string can have different translations | |
t`Hello ${ name }` | |
c('context') | |
.t`Hello ${ name }` |
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
import { ngettext, msgid } from 'c-3po'; | |
const n = 5; | |
ngettext(msgid`${ n } banana`, `${ n } bananas`, n); |
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
import { t } from 'c-3po' | |
const name = 'c-3po'; | |
t`Hello ${ name }` // translator will see "Hello ${ name }" in .po file |
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
// var a = 5; | |
// { | |
// let a = 7; | |
// console.log(`scoped ${a}`) | |
// } | |
// function test() { | |
// console.log(a); | |
// } |
NewerOlder