SharedExpressionsConfigurator
Swifternalization contains some built-in country-related shared expressions. Developer can create its own expressions in Expressions.strings file for base and preferred language version of the file.
The class is responsible for proper loading the built-in shared ones and those loaded from project’s files. It handles overriding of built-in and loads those from Base and preferred language version.
It always load base expressions, then looking for language specific. If in Base file are some expressions that overrides built-in, that’s fine the class adds or developer’s custom expressions and add only those of built-in that are not contained in the Base.
The same is for preferred languages but also here what is important is that at first preferred language file expressions are loaded, then if something different is defined in Base it will be also loaded and then the built-in expression that differs.
-
Method takes expression for both Base and preferred language localizations and also internally loads built-in expressions, combine them and returns tuple with expressions for Base and another array for preferred language localization.
Declaration
Swift
class func configureExpressions(dicts: BasePrefDicts, language: Language) -> (base: [SharedExpression], pref: [SharedExpression])
Parameters
dicts
A
BasePrefDicts
tuple that contains two dicts of shared expressions for Base and preferred language localization.language
A preferred user’s language.
Return Value
Tuple with arrays of shared expressions for Base and preferred language localizations.
-
Converts dictionary with expressions to array of
SharedExpression
objects.Declaration
Swift
private class func convert(expressionsDict: KVDict) -> [SharedExpression]
Parameters
expressionsDict
Dictionary with key-value pair of expression from Expressions.strings.
Return Value
Array of
SharedExpression
objects. -
Method loads built-in framework’s built-in expressions for specific language.
Declaration
Swift
private class func loadBuiltInExpressions(language: Language) -> [SharedExpression]
Parameters
language
A preferred user’s language.
Return Value
Shared expressions for specific language. If there is no expression for passed language empty array is returned.
-
Method that merges expressions. It takes two arrays, one is
source
and one isadditional
. If thesource
does not contain some expression fromadditional
array this expression will be added to thesource
.Declaration
Swift
private class func mergeExpressions(var source: [SharedExpression], additional: [SharedExpression]) -> [SharedExpression]
Parameters
source
A source array with expressions.
additional
Array with additional expressions that may or may not be added to
source
array.Return Value
Array with expressions that contains all elements from
source
and elements fromadditional
that were not insource
. -
This is just helper method. It does the same like
mergeExpressions(source:additional:)
but this one takes reference tosource
array instead of pasing it by value.Declaration
Swift
private class func mergeExpressions(inout source: [SharedExpression], additional: [SharedExpression]) -> Void
Parameters
source
reference to source array.
additional
Array of additional shared expressions.
Return Value
merged array of shared expressions.