The Augmented.js Next - Resource Bundle.
npm install next-core-bundleAugmented.js Next Core - Resource Bundle
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
- ResourceBundle
- Parameters
- \_fallback
- Properties
- \_bundle
- Properties
- \_delimiter
- Properties
- get
- Parameters
- Properties
- Properties
- Properties
- MessageKeyFormatter
- Parameters
- \_delimiter
- Properties
- format
- Parameters
- MapFormatter
- format
- Parameters
- Examples
ResourceBundle
- options (optional, default {})
#### Properties
- fallback boolean Is fallback support enabled
#### Properties
- bundle object The bundle used
#### Properties
- delimiter string The key delimiter (if fallback is enabled)
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
##
- locale string The locale
##
- language string The language
##
- 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
- options (optional, default {})
Key Delimiter
#### Properties
- delimiter string The delimter used to seperate each key
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 - Maps a JSON object of keys to new text
Replaces a string with replacement text from a JSON object.
Will replace all instances marked with the key name
#### Parameters
- message string The original string
- replacements object Object with replacement strings
#### Examples
``javascript``
const message = MapFormatter.format("This is a test of {ebs}.", { "ebs": "the Emergency Broadcast System" });
Returns string Returns the string with replaced text