How to use the intl-relativeformat.default function in intl-relativeformat

To help you get started, we’ve selected a few intl-relativeformat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github onap / sdc / openecomp-ui / src / nfvo-utils / i18n / i18n.js View on Github external
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
import IntlObj from 'intl';
import IntlMessageFormatObj from 'intl-messageformat';
import IntlRelativeFormatObj from 'intl-relativeformat';
import createFormatCacheObj from 'intl-format-cache';
import i18nJson from 'i18nJson';
/*
 Intl libs are using out dated transpailer from ecmascript6.
 *  TODO: As soon as they fix it, remove this assignments!!!
 * */
var Intl = window.Intl || IntlObj.default,
    IntlMessageFormat = IntlMessageFormatObj.default,
    IntlRelativeFormat = IntlRelativeFormatObj.default,
    createFormatCache = createFormatCacheObj.default;

/*extract locale*/
var _locale = window.localStorage && localStorage.getItem('user_locale');
if (!_locale) {
    if (window.navigator) {
        _locale = navigator.language || navigator.userLanguage;

        //For now removing the dashes from the language.
        let indexOfDash = _locale.indexOf('-');
        if (-1 !== indexOfDash) {
            _locale = _locale.substr(0, indexOfDash);
        }
    }
    if (!_locale) {
        _locale = 'en';

intl-relativeformat

Formats JavaScript dates to relative time strings.

BSD-3-Clause
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis