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
See more at stefan-majiros.com! |
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
const crypto = require('crypto'); | |
const base64url = require('base64url'); | |
const cbor = require('cbor'); | |
const jsrsasign = require('jsrsasign'); | |
let gsr2 = 'MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9iYWxzaWduLm5ldC9yb290LXI |
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
node makeTranslations.js | |
// 💖 or if you used global installation of translate-json-object library, you would need to use | |
NODE_PATH=$(npm root -g) node ./scripts/makeTranslations.js | |
// 💖 or add it as npm script into package.json, so you would run it w/ npm run checkTranslations command | |
"checkTranslations": "NODE_PATH=$(npm root -g) node ./scripts/makeTranslations.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
module.exports = [ | |
'af', 'am','az', 'be', 'bg', 'bn', 'bs', 'ca', | |
'co', 'cs', 'cy', 'da', 'de', 'el', 'en', 'eo', | |
'es', 'et', 'eu', 'fa', 'fi', 'fr', 'fy', 'ga', | |
'gd', 'gl', 'gu', 'ha', 'hi', 'hr', 'ht', 'hu', | |
'hy', 'id', 'ig', 'is', 'it', 'iw', 'ja', 'jw', | |
'ka', 'kk', 'km', 'kn', 'ko', 'ku', 'ky', 'la', | |
'lb', 'lo', 'lt', 'lv', 'mg', 'mi', 'mk', 'ml', | |
'mn', 'mr', 'ms', 'mt', 'my', 'ne', 'nl', 'no', | |
'ny', 'pl', 'ps', 'pt', 'ro', 'ru', 'sd', 'si', |
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
const {createWriteStream} = require('fs'); | |
// installed from my own repository , globally | |
var TJO = require('translate-json-object')(); | |
// 💖 | |
var json_SOURCE_OF_TRUTH = require('../src/localization/translations/en.json'); | |
var supportedLanguages = require('./supportedLanguages'); | |
var fs = require('fs'); | |
var path = require('path'); |
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 React from 'react'; | |
import { | |
FlatList, | |
InteractionManager, | |
StyleSheet, | |
TouchableOpacity, | |
View, | |
} from 'react-native'; | |
import * as Animatable from 'react-native-animatable'; | |
import {currentLocale, translate} from '../localization'; |
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 moment from 'moment'; | |
import {momentLocalesFileMappings} from './translationFileMappings'; | |
const DATE_FORMAT = 'YYYY-DD-MM'; | |
// 💖 Here we tell moment to change locale in runtime | |
export const setMomentLocale = async locale => { | |
momentLocalesFileMappings[locale](); | |
return moment().locale(locale); | |
}; |
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
export const momentLocalesFileMappings = { | |
// lazy requires (metro bundler does not support symlinks) | |
af: () => require('moment/locale/af'), | |
ar: () => require('moment/locale/ar'), | |
az: () => require('moment/locale/az'), | |
be: () => require('moment/locale/be'), | |
bg: () => require('moment/locale/bg'), | |
bn: () => require('moment/locale/bn'), | |
bs: () => require('moment/locale/bs'), | |
ca: () => require('moment/locale/ca'), |
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
export const translationFileMappings = { | |
// lazy requires (metro bundler does not support symlinks) | |
af: () => require('./translations/af.json'), | |
am: () => require('./translations/am.json'), | |
az: () => require('./translations/az.json'), | |
be: () => require('./translations/be.json'), | |
bg: () => require('./translations/bg.json'), | |
bn: () => require('./translations/bn.json'), | |
bs: () => require('./translations/bs.json'), | |
ca: () => require('./translations/ca.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
import i18n from 'i18n-js'; | |
import memoize from 'lodash.memoize'; | |
// 💖 we will use translate in our components | |
export const translate = memoize((key, config) => i18n.t(key, config)); | |
export const currentLocale = () => i18n.locale; | |
// 💖 this is function responsinble for changing locale | |
export const setI18nConfig = async languageTag => { |