Skip to content

Commit 8385312

Browse files
committed
fix: Add missing underscore / dash replace on getPluralIndex
1 parent e1a5314 commit 8385312

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/utils/get-plural-index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2005-2010 - Zend Technologies USA Inc. (http://www.zend.com)
77
*/
88
export function getPluralIndex(lang: string, number: number): number {
9-
switch (lang) {
9+
switch (lang.replace('_', '-')) {
1010
case 'az':
1111
case 'az-AZ':
1212
case 'bo':

test/fixtures/lang/zh_TW.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"Welcome!": "歡迎"
3+
}

test/translate.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,10 @@ it('returns the active lang', async () => {
7272
await loadLanguageAsync('en');
7373
expect(getActiveLanguage()).toBe('en');
7474
})
75+
76+
it('translates to a underscore/dash language', async () => {
77+
await global.mountPlugin();
78+
79+
await loadLanguageAsync('zh_TW');
80+
expect(getActiveLanguage()).toBe('zh_TW');
81+
})

0 commit comments

Comments
 (0)