Skip to content

litejs/i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@litejs/i18n – Coverage size Buy Me A Tea

Translation, pluralization, date and number formating.

i18n.def({"en": "In English"})
i18n.add("en", {
	// Numbers extension namespace
	"#": {
		".05": "# ###.05",     // Number rounded to .05
		"gas": "#/8",          // Fractions
		"money": " $# ###,05 ;n\a;($# ###,05);zero"
	},
	// Pluralization extension namespace
	"*": {
		"message": "one message;# messages"
	},
	// Selection extension namespace
	"?": {
		"friend": "friend;male=boyfriend;female=girlfriend"
	},
	// Date and time extension namespace
	"@": {
		"LT": "h:mm a",        // Local Time
		"LD": "MM/DD/y"        // Local Date
	},
	"welcome": "Hello, {user.name}!",
	"inbox": "You have {count;*message} from your {friend.sex;?friend}!"
})
var data = { user: {name: "Bob"}, count: 15, friend: { sex: "female" } })
i18n("welcome", data)
// Hello, Bob!
i18n("inbox", data)
// You have 15 messages from your girlfriend!

See wiki for more.

Licence

Copyright (c) 2021 Lauri Rooden <lauri@rooden.ee>
The MIT License | Source code

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published