Skip to content

Commit

Permalink
feat: using new dynamic localization (#23)
Browse files Browse the repository at this point in the history
Co-authored-by: Dave Lockhart <“[email protected]”>
  • Loading branch information
dlockhart and Dave Lockhart authored Mar 1, 2021
1 parent efa59d1 commit ae57844
Show file tree
Hide file tree
Showing 20 changed files with 11 additions and 80 deletions.
6 changes: 3 additions & 3 deletions src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function getOptions() {
{
type: 'text',
name: 'codeowners',
message: 'What is/are the github username(s) of the codeowner(s)? (e.g., @janesmith, @johnsmith)'
message: 'What is/are the GitHub username(s) of the codeowner(s)? (e.g., @janesmith, @johnsmith)'
},
{
type: 'select',
Expand All @@ -64,9 +64,9 @@ async function getOptions() {
name: 'localizationType',
message: 'What type of localization would you like?',
choices: [
{ title: 'Static', value: 'static' },
{ title: 'Dynamic (no serge)', value: 'dynamic' },
{ title: 'Dynamic (yes serge)', value: 'serge' }
{ title: 'Dynamic (yes serge)', value: 'serge' },
{ title: 'Static', value: 'static' }
]
},
];
Expand Down
11 changes: 8 additions & 3 deletions src/generators/localization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const staticLocalization = `\n\tstatic async getLocalizeResources(langs) {
return null;
}\n`;
const dynamicLocalization = `\n\tstatic get localizeConfig() {
return {
importFunc: async lang => (await import(\`./lang/\${lang}.js\`)).default
};
}\n`;

export function run(templateData) {
const replacements = {
Expand All @@ -27,9 +32,9 @@ export function run(templateData) {
replacements.localizeMixin = 'import { LocalizeMixin } from \'@brightspace-ui/core/mixins/localize-mixin.js\';\n';
replacements.localizeResources = staticLocalization;
} else {
replacements.extends = 'LocalizeElement(LitElement)';
replacements.localizeMixin = 'import { LocalizeElement } from \'./locales/localize-element.js\';\n';
replacements.localizeResources = '';
replacements.extends = 'LocalizeDynamicMixin(LitElement)';
replacements.localizeMixin = 'import { LocalizeDynamicMixin } from \'@brightspace-ui/core/mixins/localize-dynamic-mixin.js\';\n';
replacements.localizeResources = dynamicLocalization;

copyFilesInDir(`${__dirname}/templates/static`, getDestinationPath(templateData.hyphenatedName));
}
Expand Down

This file was deleted.

0 comments on commit ae57844

Please sign in to comment.