Skip to content

Commit

Permalink
Merge branch 'setlocale-not-updating-wikilinks'
Browse files Browse the repository at this point in the history
  • Loading branch information
iiirxs committed Jan 28, 2022
2 parents ab75950 + d4b7f46 commit c37bbbe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 2 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

0 comments on commit c37bbbe

Please sign in to comment.