mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-27 05:49:49 +09:00
fix: update npm dependencies, fix misc issues (#38257)
Update all npm dependencies and fix discovered issues. Co-authored-by: bircni <bircni@icloud.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
co-authored by
bircni
silverwind
wxiaoguang
parent
e68ee61879
commit
07b18467c0
@@ -1,15 +1,10 @@
|
||||
import {trN} from './i18n.ts';
|
||||
import {getCurrentLocale} from '../utils.ts';
|
||||
|
||||
vi.mock('../utils.ts', () => ({getCurrentLocale: vi.fn()}));
|
||||
|
||||
test('trN', () => {
|
||||
vi.mocked(getCurrentLocale).mockReturnValue('en-US');
|
||||
expect(trN(0, '%d job', '%d jobs')).toEqual('0 jobs');
|
||||
expect(trN(1, '%d job', '%d jobs')).toEqual('1 job');
|
||||
expect(trN(2, '%d job', '%d jobs')).toEqual('2 jobs');
|
||||
expect(trN(1000, '%d job', '%d jobs')).toEqual('1000 jobs');
|
||||
expect(trN(0, '%d job', '%d jobs', {lang: 'en-US'})).toEqual('0 jobs');
|
||||
expect(trN(1, '%d job', '%d jobs', {lang: 'en-US'})).toEqual('1 job');
|
||||
expect(trN(2, '%d job', '%d jobs', {lang: 'en-US'})).toEqual('2 jobs');
|
||||
expect(trN(1000, '%d job', '%d jobs', {lang: 'en-US'})).toEqual('1000 jobs');
|
||||
// languages without a distinct singular always use the plural form
|
||||
vi.mocked(getCurrentLocale).mockReturnValue('zh-CN');
|
||||
expect(trN(1, '%d job', '%d jobs')).toEqual('1 jobs');
|
||||
expect(trN(1, '%d job', '%d jobs', {lang: 'zh-CN'})).toEqual('1 jobs');
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {getCurrentLocale} from '../utils.ts';
|
||||
|
||||
/** frontend `Locale.TrN`: pick the `_1` or `_n` form for `count` and interpolate `%d` */
|
||||
export function trN(count: number, form1: string, formN: string): string {
|
||||
const form = new Intl.PluralRules(getCurrentLocale()).select(count) === 'one' ? form1 : formN;
|
||||
export function trN(count: number, form1: string, formN: string, {lang = getCurrentLocale()}: {lang?: string} = {}): string {
|
||||
const form = new Intl.PluralRules(lang).select(count) === 'one' ? form1 : formN;
|
||||
return form.replace('%d', String(count));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user