mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	Introduce GiteaLocaleNumber custom element to handle number localization on pages. (#23861)
Follow #21429 & #22861 Use `<gitea-locale-number>` instead of backend `PrettyNumber`. All old `PrettyNumber` related functions are removed. A lot of code could be simplified. And some functions haven't been used for long time (dead code), so they are also removed by the way (eg: `SplitStringAtRuneN`, `Dedent`) This PR only tries to improve the `PrettyNumber` rendering problem, it doesn't touch the "plural" problem. Screenshot:  
This commit is contained in:
		| @@ -1,7 +1,7 @@ | ||||
| import {expect, test} from 'vitest'; | ||||
| import { | ||||
|   basename, extname, isObject, stripTags, joinPaths, parseIssueHref, | ||||
|   prettyNumber, parseUrl, translateMonth, translateDay, blobToDataURI, | ||||
|   parseUrl, translateMonth, translateDay, blobToDataURI, | ||||
|   toAbsoluteUrl, | ||||
| } from './utils.js'; | ||||
|  | ||||
| @@ -84,17 +84,6 @@ test('parseIssueHref', () => { | ||||
|   expect(parseIssueHref('')).toEqual({owner: undefined, repo: undefined, type: undefined, index: undefined}); | ||||
| }); | ||||
|  | ||||
| test('prettyNumber', () => { | ||||
|   expect(prettyNumber()).toEqual(''); | ||||
|   expect(prettyNumber(null)).toEqual(''); | ||||
|   expect(prettyNumber(undefined)).toEqual(''); | ||||
|   expect(prettyNumber('1200')).toEqual(''); | ||||
|   expect(prettyNumber(12345678, 'en-US')).toEqual('12,345,678'); | ||||
|   expect(prettyNumber(12345678, 'de-DE')).toEqual('12.345.678'); | ||||
|   expect(prettyNumber(12345678, 'be-BE')).toEqual('12 345 678'); | ||||
|   expect(prettyNumber(12345678, 'hi-IN')).toEqual('1,23,45,678'); | ||||
| }); | ||||
|  | ||||
| test('parseUrl', () => { | ||||
|   expect(parseUrl('').pathname).toEqual('/'); | ||||
|   expect(parseUrl('/path').pathname).toEqual('/path'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 wxiaoguang
					wxiaoguang