-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(sw): use fully typed locales (#14470)
* refactor(sw): use fully typed locales * fix(backend): enumerate achievement notification type
- Loading branch information
Showing
8 changed files
with
89 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import { describe, expect, it } from 'vitest'; | ||
import { I18n } from '@/scripts/i18n.js'; | ||
import { ParameterizedString } from '../../../locales/index.js'; | ||
|
||
describe('i18n', () => { | ||
it('t', () => { | ||
const i18n = new I18n({ | ||
foo: 'foo', | ||
bar: { | ||
baz: 'baz', | ||
qux: 'qux {0}' as unknown as ParameterizedString<'0'>, | ||
quux: 'quux {0} {1}' as unknown as ParameterizedString<'0' | '1'>, | ||
}, | ||
}); | ||
|
||
expect(i18n.t('foo')).toBe('foo'); | ||
expect(i18n.t('bar.baz')).toBe('baz'); | ||
expect(i18n.tsx.bar.qux({ 0: 'hoge' })).toBe('qux hoge'); | ||
expect(i18n.tsx.bar.quux({ 0: 'hoge', 1: 'fuga' })).toBe('quux hoge fuga'); | ||
}); | ||
it('ts', () => { | ||
const i18n = new I18n({ | ||
foo: 'foo', | ||
bar: { | ||
baz: 'baz', | ||
qux: 'qux {0}' as unknown as ParameterizedString<'0'>, | ||
quux: 'quux {0} {1}' as unknown as ParameterizedString<'0' | '1'>, | ||
}, | ||
}); | ||
|
||
expect(i18n.ts.foo).toBe('foo'); | ||
expect(i18n.ts.bar.baz).toBe('baz'); | ||
}); | ||
it('tsx', () => { | ||
const i18n = new I18n({ | ||
foo: 'foo', | ||
bar: { | ||
baz: 'baz', | ||
qux: 'qux {0}' as unknown as ParameterizedString<'0'>, | ||
quux: 'quux {0} {1}' as unknown as ParameterizedString<'0' | '1'>, | ||
}, | ||
}); | ||
|
||
expect(i18n.tsx.bar.qux({ 0: 'hoge' })).toBe('qux hoge'); | ||
expect(i18n.tsx.bar.quux({ 0: 'hoge', 1: 'fuga' })).toBe('quux hoge fuga'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.