Skip to content
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

Dynamic localization #310

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

marian-ene-customsoft
Copy link

The changes would allow leveraging the {{ lang }} handlebar params to dynamically switch the current language on the BigCommerce StoreFront.

It would work verry well with a new handlebar for retrieving a query parameter as shown bellow
`'use strict';
const utils = require('handlebars-utils');
const common = require('./lib/common.js');

const factory = globals => {
return function(url, key) {
url = common.unwrapIfSafeString(globals.handlebars, url);
if (utils.isString(url)) {
const decodedURL = unescape(url);
const query = decodedURL.split('?');
if (query.length > 1) {
const params = new URLSearchParams(query[1]);
return params.get(key);
} else return 'en';
}
};
};

module.exports = [{
name: 'getURLQueryParam',
factory: factory,
}];`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant