next-core-bundle
v3.2.3
Published
The Augmented.js Next - Resource Bundle.
Downloads
15
Maintainers
Readme
next-core-bundle
Augmented.js Next Core - Resource Bundle
Description
Resource bundles contain locale-specific objects. When your program needs a locale-specific resource, a String for example, your program can load it from the resource bundle that is appropriate for the current user's locale. In this way, you can write program code that is largely independent of the user's locale isolating most, if not all, of the locale-specific information in resource bundles.
This allows you to write programs that can:
- be easily localized, or translated, into different languages
- handle multiple locales at once
- be easily modified later to support even more locales
API
Table of Contents
ResourceBundle
ResourceBundle
Parameters
options
(optional, default{}
)
_fallback
Properties
fallback
boolean Is fallback support enabled
_bundle
Properties
bundle
object The bundle used
_delimiter
Properties
delimiter
string The key delimiter (if fallback is enabled)
get
Get a string from the bundle by key
Parameters
key
string The key to find in the bundle
Returns string Message from bundle, [key] if not found, or null if missing the key
Properties
locale
string The locale
Properties
language
string The language
Properties
country
string The country
MessageKeyFormatter
Concatenate the pieces of the message together if a portion of the key is missing, the rest of the key is ignored. ex. if the "rule" attribute is missing, then the key will return with the message.level + message.kind only
Parameters
options
(optional, default{}
)
_delimiter
Key Delimiter
Properties
delimiter
string The delimter used to seperate each key
format
Format a key for a message
Parameters
message
object The message to format (optional, default{}
)
Returns any The key to lookup in a bundle
MapFormatter
MapFormatter - Maps a JSON object of keys to new text
format
Replaces a string with replacement text from a JSON object.
Will replace all instances marked with the key name
Parameters
Examples
const message = MapFormatter.format("This is a test of {ebs}.", { "ebs": "the Emergency Broadcast System" });
Returns string Returns the string with replaced text