${language}
with "en"
in the path) and return the value. Note: This will load the file on each request. To have values cached, use the cp.strings
module and specify a plist
as a source.cp.strings:context([context]) -> table | self
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Gets or sets a context to be set for the strings. This typically includes a language
, which | | Parameters |cp.string.source
is returned, otherwise the current context table is returned.cp.strings:find(key[, context[, quiet]) -> string | nil
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Searches for the specified key, caching the result when found. | | Parameters |key
- The key to retrieve from the file.context
- Optional table with additional/alternate context.quiet
- Optional boolean, defaults to false
. If true
, no warnings are logged for missing keys.nil
if not found.cp.strings:findInSources(key[, context[, quiet]]) -> string | nil
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Searches directly in the sources for the specified key. | | Parameters |key
- The key to retrieve from the file.context
- Optional table with additional/alternate context.quiet
- Optional boolean, defaults to false
. If true
, no warnings are logged for missing keys.nil
if not found.cp.strings:findKeys(value[, context]) -> string | nil
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Searches for the list of keys with a matching value, in the specified language. | | Parameters |value
- The value to search for.context
- The language code to look for (e.g. "en"
, or "fr"
).{}
if not found.cp.strings:findKeysInSources(value[, context]) -> string | nil
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Searches directly in the sources for the specified key value pattern. | | Parameters |value
- The value to search for.context
- Optional additional context for the request.{}
if not found.cp.strings:from(source) -> cp.strings
source
- The source to add.cp.strings
instance.cp.strings:fromPlist(pathPattern) -> cp.strings
plist
source to the strings instance.pathPattern
- The path to load from. May contain a special ${language}
marker which will be replace with the provided langauge when searching.cp.strings
instance.