diff --git a/package.json b/package.json index d9ddf4c..4767209 100644 --- a/package.json +++ b/package.json @@ -45,9 +45,11 @@ "glob": "^7.1.6", "js-yaml": "^3.13.1", "load-json-file": "^6.2.0", + "lodash.mapvalues": "^4.6.0", "lodash.merge": "^4.6.2", "lodash.mergewith": "^4.6.2", "lodash.pick": "^4.4.0", + "lodash.pickby": "^4.6.0", "meow": "^6.1.0", "mkdirp": "^1.0.3", "pify": "^5.0.0", diff --git a/src/extract-react-intl/index.ts b/src/extract-react-intl/index.ts index 83367e8..1ce7db3 100644 --- a/src/extract-react-intl/index.ts +++ b/src/extract-react-intl/index.ts @@ -74,6 +74,12 @@ type Message = { id: string defaultMessage: string description: string + partners?: string; + partnerVariations?: PartnerVariations +} + +interface PartnerVariations { + [key: string]: string } // eslint-disable-next-line max-lines-per-function @@ -127,16 +133,20 @@ export default async ( presets: resolvePresets(presets, babelrcDir), plugins: resolvePlugins(plugins, babelrcDir) } + const { metadata } = await pify(transformFile)(file, babelOpts) + const localeObj = localeMap(locales) + console.log('>>>', localeMap(locales)) const result = metadata['react-intl'].messages as Message[] - for (const { id, defaultMessage, description } of result) { + console.log('json===', JSON.parse(JSON.stringify(result, null, 2))) + for (const { id, defaultMessage, description, partners, partnerVariations } of result) { // eslint-disable-next-line no-unused-vars for (const locale of locales) { const message = defaultLocale === locale ? defaultMessage : '' localeObj[locale][id] = withDescriptions - ? { message, description } - : message + ? { message, description, partners, partnerVariations } + : {message, partners, partnerVariations}; } } return localeObj diff --git a/src/index.ts b/src/index.ts index fedc455..184fb71 100644 --- a/src/index.ts +++ b/src/index.ts @@ -138,4 +138,4 @@ export default extractMessage // For CommonJS default export support module.exports = extractMessage -module.exports.default = extractMessage +module.exports.default = extractMessage \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index be0d574..d3c39ab 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "@akameco/tsconfig", "compilerOptions": { - "outDir": "dist" + "outDir": "dist", + "target": "ES2017" }, "include": ["src"] } diff --git a/yarn.lock b/yarn.lock index a09ed32..c921e26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4134,6 +4134,11 @@ lodash.has@4.5.2: resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862" integrity sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI= +lodash.mapvalues@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz#1bafa5005de9dd6f4f26668c30ca37230cc9689c" + integrity sha512-JPFqXFeZQ7BfS00H58kClY7SPVeHertPE0lNuCyZ26/XlN8TvakYD7b9bGyNmXbT/D3BbtPAAmq90gPWqLkxlQ== + lodash.memoize@4.x: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" @@ -4154,6 +4159,11 @@ lodash.pick@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM= +lodash.pickby@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.pickby/-/lodash.pickby-4.6.0.tgz#7dea21d8c18d7703a27c704c15d3b84a67e33aff" + integrity sha512-AZV+GsS/6ckvPOVQPXSiFFacKvKB4kOQu6ynt9wz0F3LO4R9Ij4K1ddYsIytDpSgLz88JHd9P+oaLeej5/Sl7Q== + lodash.sortby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"