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

Setlocale not updating wikilinks #61

Merged
merged 3 commits into from Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "banana-i18n",
"version": "2.3.2",
"version": "2.3.3",
"description": "Banana Internationalization library",
"main": "dist/banana-i18n.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Expand Up @@ -20,6 +20,7 @@ export default class Banana {
this.load(messages, this.locale)
}
this.finalFallback = finalFallback
this.wikilinks = wikilinks
}

/**
Expand All @@ -39,7 +40,7 @@ export default class Banana {
setLocale (locale) {
this.locale = locale
// Update parser
this.parser = new BananaParser(this.locale)
this.parser = new BananaParser(this.locale, { wikilinks: this.wikilinks })
}

getFallbackLocales () {
Expand Down
9 changes: 9 additions & 0 deletions test/banana.test.js
Expand Up @@ -788,6 +788,9 @@ describe('Banana', function () {
'msg-with-wikilink': 'This is a link to [[Apple|Apple Page]]',
'msg-with-wikilink-no-anchor': 'This is a link to [[Apple]]'
}, 'en')
banana.load({
'msg-with-extlink': 'ഇത് [https://wikipedia.org വിക്കിപീഡീയ] ലിങ്ക്'
}, 'ml')
assert.strictEqual(
banana.i18n('msg-with-extlink'),
'This is a link to <a href="https://wikipedia.org">wikipedia</a>',
Expand All @@ -803,6 +806,12 @@ describe('Banana', function () {
'This is a link to <a href="./Apple" title="Apple">Apple</a>',
'Internal Wiki style link with link and title being same'
)
banana.setLocale('ml')
assert.strictEqual(
banana.i18n('msg-with-extlink'),
'ഇത് <a href="https://wikipedia.org">വിക്കിപീഡീയ</a> ലിങ്ക്',
'External link, after changing locale'
)
})

it('should skip wiki links if disabled', () => {
Expand Down