transifex-config

Modules

transifex-config/lib/errors
transifex-config/lib/load-config
transifex-config/lib/match-resourcestring | boolean
transifex-config/lib/parse-langmapRecord.<string, string>

Parses the language map.

transifex-config/lib/parse-rcmodule:transifex-config~ParsedConfig

Parse a transifex client configuration file. Looks at the file line by line.

Classes

transifex-config

Constants

MAP_MIN_LENGTH

Functions

_getRC([service])module:transifex-config~ParsedConfig
matchFileFilter(basePath, localPath, fileFilter)string | boolean

Check if a file matches the file_filter rule.

ensureObjectKeyPath(keyPath, object)object

Typedefs

ConfigSection : Record.<string, string>

Has a property for each key in the section, with trimmed name and value.

ParsedConfig : Record.<string, module:transifex-config~ConfigSection>

Has a property for each section in the config. Each section has a property named after the key with its value assigned.

transifex-config/lib/errors

Author: Martin Giger
License: MIT

transifex-config/lib/errors.NoMatchingResourceError

Kind: static class of transifex-config/lib/errors
Implements: Error

new exports.NoMatchingResourceError(resource)

Param Type Description
resource string Path to the resource that has no matching config entry.

transifex-config/lib/errors.MatchesSourceError

Kind: static class of transifex-config/lib/errors
Implements: Error

new exports.MatchesSourceError(resource)

Param Type Description
resource string Path to the resource that is the source file.

transifex-config/lib/load-config

Author: Martin Giger
License: MIT

transifex-config/lib/load-config.TRANSIFEXRC : string

File name of the config file from the base path.

Kind: static constant of transifex-config/lib/load-config
Read only: true

transifex-config/lib/load-config.TXCONFIG : string

File name of the rc file from the base path.

Kind: static constant of transifex-config/lib/load-config
Read only: true

transifex-config/lib/load-config.txconfig(basePath) ⇒ module:transifex-config~ParsedConfig

Loads and parses the transifex client config.

Kind: static method of transifex-config/lib/load-config
Returns: module:transifex-config~ParsedConfig - Parsed contents of the config.
Throws:

Param Type Description
basePath string Path the config is in.

transifex-config/lib/load-config.transifexrc(basePath, [service]) ⇒ module:transifex-config~ParsedConfig

Loads and parses the transifex login info.

Kind: static method of transifex-config/lib/load-config
Returns: module:transifex-config~ParsedConfig - Parsed contents of the rc.
Throws:

Param Type Description
basePath string Path the rc is in.
[service] string Service host the RC should contain.

transifex-config/lib/load-config~loadConfig(configPath) ⇒ string

Loads a file from the given path and returns its contents.

Kind: inner method of transifex-config/lib/load-config
Returns: string - Contents of the file.
Throws:

Param Type Description
configPath string Path to the file to load.

transifex-config/lib/load-config~normalizeRC(rc) ⇒ module:transifex-config~ParsedConfig

Fixes the header names of the RC by re-assembling the host names instead of each domain part being a subsection.

Kind: inner method of transifex-config/lib/load-config
Returns: module:transifex-config~ParsedConfig - Normalized RC.

Param Type Description
rc object RC to normalize.

transifex-config/lib/match-resource ⇒ string | boolean

Returns: string | boolean - Returns the language if the file matches the resource, else returns false.

Param Type Description
basePath string Base path to the transifex config.
localPath string Full path to the resource file to match.
resource string Resource to check if the local file matches.

transifex-config/lib/parse-langmap ⇒ Record.<string, string>

Parses the language map.

Returns: Record.<string, string> - A map of the language, with the local language code as key and the remote language code as value.

Param Type Default Description
[langMapString] string "''" Language map specification.
[langMap] object {} Language map to inherit from.

transifex-config/lib/parse-rc ⇒ module:transifex-config~ParsedConfig

Parse a transifex client configuration file. Looks at the file line by line.

Returns: module:transifex-config~ParsedConfig - Configuration file represented as an object.

Param Type Description
content string Configuration file contents.

transifex-config

Kind: global class

new TransifexConfig([basePath])

Throws:

Param Type Default Description
[basePath] string "require(\"app-root-path\")" Path the transifex configuration is in. Defaults to the best guess of the package root.

transifex-config.basePath : string

Base path the config is read from.

Kind: instance property of transifex-config

transifex-config.getRC ⇐ module:transifex-config~\_getRC

Memoized version of module:transifex-config~_getRC.

Kind: instance property of transifex-config
Extends: module:transifex-config~\_getRC

transifex-config.getConfig() ⇒ module:transifex-config~ParsedConfig

Kind: instance method of transifex-config
Returns: module:transifex-config~ParsedConfig - Parsed .tx/config as an object. Will be cached.
Throws:

transifex-config.getResources() ⇒ Array.<module:transifex-config~ConfigSection>

Kind: instance method of transifex-config
Returns: Array.<module:transifex-config~ConfigSection> - Array of resources.
Throws:

transifex-config.getResource(localPath, [matchSourceLang]) ⇒ module:transifex-config~ConfigSection

Kind: instance method of transifex-config
Returns: module:transifex-config~ConfigSection - Config section for the resource.
Throws:

Param Type Description
localPath string Absolute local path of the resource to return the config entry of.
[matchSourceLang] boolean If the resource should be returned when the path is for the source language of the resource.

transifex-config.isSourceResource(resourcePath) ⇒ boolean

Check if a resource is the source resource.

Kind: instance method of transifex-config
Returns: boolean - If the resource is the source.
Throws:

Param Type Description
resourcePath string Path to check.

transifex-config.getMappedLang(lang, resource) ⇒ string

Kind: instance method of transifex-config
Returns: string - Mapped language code.
Throws:

Param Type Description
lang string Language code to map from local to external.
resource module:transifex-config~ConfigSection Resource to get map the language for.

MAP_MIN_LENGTH

Kind: global constant
Author: Martin Giger
License: MIT

_getRC([service]) ⇒ module:transifex-config~ParsedConfig

Kind: global function
Returns: module:transifex-config~ParsedConfig - Parsed .transifexrc as an object. Will be cached.
Throws:

this: {TransifexConfig}

Param Type Description
[service] string The config should contain this service URL.

matchFileFilter(basePath, localPath, fileFilter) ⇒ string | boolean

Check if a file matches the file_filter rule.

Kind: global function
Returns: string | boolean - REturns the language the file matches or false.

Param Type Description
basePath string Base path to the transifex config.
localPath string Full path to the resource file to match.
fileFilter string File filter the resource should match.

ensureObjectKeyPath(keyPath, object) ⇒ object

Kind: global function
Returns: object - Reference to the object with the requested keys.

Param Type Description
keyPath Array.<string> Path of keys that should be present in the nested object.
object object Object to ensure the keys exist on.

ConfigSection : Record.<string, string>

Has a property for each key in the section, with trimmed name and value.

Kind: global typedef

ParsedConfig : Record.<string, module:transifex-config~ConfigSection>

Has a property for each section in the config. Each section has a property named after the key with its value assigned.

Kind: global typedef