8000 Feature/CTXAPI-1831 multiple locales hash name by joaquinlencinas · Pull Request #410 · Medable/mdctl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature/CTXAPI-1831 multiple locales hash name #410

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

Merged
Merged
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
30 changes: 14 additions & 16 deletions packages/mdctl-core/streams/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const _ = require('lodash'),
NON_WRITABLE_KEYS = ['facet'],
SectionsCreated = [],
{ privatesAccessor } = require('@medable/mdctl-core-utils/privates'),
hash = require('crypto').createHash('md5')
crypto = require('crypto')

class ExportSection {

Expand Down Expand Up @@ -273,6 +273,19 @@ class ExportSection {
if (_.isArray(content.localizations)) {
const name = `${content.object}.${content.type}.${content.name}`
content.localizations.forEach((l, locIdx) => {
let localeInName
if (_.isArray(l.locale)) {
if (l.locale.length > 1) {
localeInName = crypto.createHash('md5').update(l.locale.join()).digest('hex')
} else if (_.isEqual(l.locale, ['*'])) {
localeInName = 'anyLocale'
} else {
localeInName = l.locale[0]
}
} else {
localeInName = l.locale
}

const nodes = jp.nodes(l, '$..content')
nodes.forEach((n) => {
const parentPath = ['$', 'localizations', locIdx]
Expand All @@ -283,21 +296,6 @@ class ExportSection {
objectPath.push(i)
objectPath.push('data')
if (cnt.data) {
let localeInName;
if (_.isArray(l.locale)){
if(l.locale.length > 1) {
localeInName = hash.update(l.locale.join()).digest('hex')
} else {
if (_.isEqual(l.locale, ['*'])) {
localeInName = 'anyLocale'
} else {
localeInName = l.locale[0]
}
}
} else {
localeInName = l.locale
}

privatesAccessor(this).templateFiles.push({
name: `${name}.${localeInName}.${cnt.name}`,
ext: TEMPLATES_EXT[content.type][cnt.name],
Expand Down
Loading
0