import { camelCase , mapKeys } from 'lodash' ; import { join } from 'path' ; import { directories } from '../util/directories' ; import { get } from '../util/get' ; import { write } from '../util/write' ; const translations = [ ] ; for ( let translation of get ( directories . translations ) ) { translation = mapKeys ( translation , ( value , key ) : string => camelCase ( key ) ) ; translation . plural = false ; if ( typeof translation . id === 'string' ) { translation . plural = translation . id . endsWith ( '_pl' ) ; translation . id = translation . id . replace ( /_pl$/ , '' ) ; if ( /^.*_(\d{5}).*$/ . test ( translation . id ) ) { translation . id = Number ( /^.*_(\d{5}).*$/ . exec ( translation . id ) ! [ 1 ] ) ; } } if ( typeof translation . variantId === 'string' ) { translation . clothGroup = Number ( /^(\d+)_.*$|^.*_(\d+)$/ . exec ( translation . variantId ) ! [ 1 ] ) || undefined ; translation . variantId = Number ( /^.*_(\d+)$/ . exec ( translation . variantId ) ! [ 1 ] ) ; } translations . push ( translation ) ; } write ( join ( directories . sanitized , 'Translations.json' ) , translations ) ;