Skip to content

[MET-41] Partner translations #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 13 additions & 3 deletions src/extract-react-intl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ export default extractMessage

// For CommonJS default export support
module.exports = extractMessage
module.exports.default = extractMessage
module.exports.default = extractMessage
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@akameco/tsconfig",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"target": "ES2017"
},
"include": ["src"]
}
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down