Common service utilities for cross-component usage.
- Copyright:
- Kiwigrid GmbH 2014-2015
- Source:
Classes
Methods
- <inner> addUrlParameter(uri, param, value) → {string}
- <inner> doesPropertyExist(obj, prop) → {boolean}
- <inner> getLabelByLocale(key, labels, currentLocale) → {string|null}
-
<inner> addUrlParameter(uri, param, value) → {string}
-
Add or modify a parameter in given URL. It maintains the correct order or URL parts.
Parameters:
Name Type Description uri
string uri to modify param
string parameter to modify value
string value to set parameter to - Source:
Returns:
string modified url -
<inner> doesPropertyExist(obj, prop) → {boolean}
-
This method checks, if a deep property does exist in the given object.
Parameters:
Name Type Description obj
object object to check property for prop
string property given in dot notation - Source:
Returns:
boolean true if property exists -
<inner> getLabelByLocale(key, labels, currentLocale) → {string|null}
-
Returns the translation for a given key inside of an object of labels which is grouped by locale keys.
If the given locale is not found inside the labels object the function tries to fall back to the english translation, otherwise the return value is null.The key can be either in short ('en') or long ('en-US') format.
Locales only match from specific > general > fallback
i. e. 'de_AT' > 'de' > 'en'
If a general locale is not defined go straight to fallback locale.Parameters:
Name Type Description key
string translation key to search for labels
object object with all translation keys grouped by locale keys currentLocale
object the currently active locale inside of the application - Source:
Returns:
string | null the translated label or null if no translation could be found