#cp.strings.source.plist

Loads strings from a plist with allowing for a given language variation. Eg:

local plistSource = require("cp.strings.source.plist").new("/Path/To/Resources/${language}.lproj/MYLocalization.strings") local value = plistSource:find("en", "AKey")

This will load the file for the specified language (replacing ${language} with "en" in the path) and return the value. Notes: This will load the file on each request. To have values cached, use the cp.strings module and specify a plist as a source.


#API Overview

Constants - Useful values which cannot be changed

Constructors - API calls which return an object, typically one that offers API methods

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Constants

Signaturecp.strings.source.plist.defaultCacheSeconds
TypeConstant
DescriptionThe default number of seconds to cache results.
NotesNone
Sourcesrc/extensions/cp/strings/source/plist.lua line 34

#Constructors

Signaturecp.strings.source.plist.new(pathPattern[, cacheSeconds]) -> source
TypeConstructor
DescriptionCreates a new cp.strings source that loads strings from a plist file.
Parameters
  • pathPattern - The path to load from. May contain a special ${language} marker which will be replace with the provided langauge when searching.
  • cacheSeconds - (optional) How long in seconds to keep the loaded values cached in memory. Defaults to defaultCacheSeconds
Returns
  • The new plist source instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/strings/source/plist.lua line 191

#Methods

Signaturecp.strings.source.plist:context([context]) -> table | self
TypeMethod
DescriptionGets or sets a context to be set for the source. This typically includes a language, which provides the default language code, but may have other source-specific properties. Calling this method may may clear caches, etc.
Parameters
  • context - A table with values which may be used by the source.
Returns
  • If a new context is provided, the cp.string.source is returned, otherwise the current context table is returned.
Notes
  • For example:
  • lua</li><li>mySource:context({language = "fr"}) -- set the default language to French.</li><li>
ExamplesNone
Sourcesrc/extensions/cp/strings/source/plist.lua line 39

Signaturecp.strings.source.plist:find(key[, context]) -> string
TypeMethod
DescriptionFinds the specified key value in the plist, if the plist can be found, and contains matching key value.
Parameters
  • key - The key to retrieve from the file.
  • context - Optional table with additional/alternate context. It will be added to the current context temporarily.
Returns
  • The value of the key, or nil if not found.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/strings/source/plist.lua line 125

| | | | --------------------------------------------|-------------------------------------------------------------------------------------| | Signature | cp.strings.source.plist:findKeys(pattern) -> {string} | | Type | Method | | Description | Finds the array of keys who's value matches the pattern in this table. It will check that the pattern matches the beginning of the value. | | Parameters |

  • pattern - The string pattern to match.</li></ul> | | **Returns** | <ul><li>The array of keys, or ` if none were fround
| | Notes | None | | Examples | None | | Source | src/extensions/cp/strings/source/table.lua line 85 |


Signaturecp.strings.source.plist:loadFile([context]) -> string
TypeMethod
DescriptionLoads the plist file for the specified context, returning the value as a table.
Parameters
  • context - The context to determine the absolute path with. This will be added to any values provided in the default context.
Returns
  • The table for the specified language, or nil if the file doesn't exist.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/strings/source/plist.lua line 105

Signaturecp.strings.source.plist:pathToAbsolute([context]) -> string
TypeMethod
DescriptionFinds the abolute path to the plist represented by this source for the specified langauge, or nil if it does not exist.
Parameters
  • context - The context to determine the absolute path with. This will be added to any values provided in the default context.
Returns
  • The path to the file, or nil if not found.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/strings/source/plist.lua line 65

Signaturecp.strings.source.plist:reset() -> cp.strings
TypeMethod
DescriptionClears any stored key values.
Parameters
  • None
Returns
  • The current cp.strings instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/strings/source/plist.lua line 177