Skip to content

An angular service for centralizing UI strings and supporting multiple languages.

License

Notifications You must be signed in to change notification settings

andrewluetgers/ngText

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ngText

An angular service for centralizing UI strings and supporting multiple languages.

Compliment this service with a language pack like so...

angular.module("myTextBundle", ["ngText"])
	 .value("myTextBundle", {
		 en: {
			 error:					"There was an error",
			 thanks:				"Thanks!",
			 networkError:			"Network Error: %status \nThere was an error attempting to " +
			 						"connect to the server %server \nPlease check your connection and try again.",
			 accessDenied:			"Access Denied, you must log in to access \n%1",
			 loggedOut:				"Successfully logged out."
		 },
		 fr: {.....}
	 })
	 .run(function(myTextBundle, $T) {
		$T.loadTextBundle(myTextBundle);
	 });

Set the language, default is "en"

$T.setLang("fr");

Get strings

$T("thanks");

Provide data objects for string substitution by key

$T("networkError", {status: "404", server: "myserver.com"});

Provide data arrays for string substitution by index

$T("accessDenied", ["some.url.com/private"]);

Read the source and tests for more documentation and usage examples.

About

An angular service for centralizing UI strings and supporting multiple languages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published