Sha256: a4d785bd7c6ff40f2f9daf5df19c374df2e44fe539548eeeedb877998ab9a1d3

Contents?: true

Size: 646 Bytes

Versions: 9

Compression:

Stored size: 646 Bytes

Contents

pageflow.i18nUtils = {
  findTranslation: function(keys, options) {
    options = options || {};

    return _.chain(keys).reverse().reduce(function(result, key) {
      return I18n.t(key, {defaultValue: result});
    }, options.defaultValue).value();
  },

  findKeyWithTranslation: function(keys) {
    var missing = '_not_translated';

    return _(keys).detect(function(key) {
      return I18n.t(key, {defaultValue: missing}) !== missing;
    }) || _.first(keys);
  },

  translationKeysWithSuffix: function(keys, suffix) {
    return _.chain(keys).map(function(key) {
      return [key + '_' + suffix, key];
    }).flatten().value();
  }
};

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pageflow-0.11.4 app/assets/javascripts/pageflow/ui/utils/i18n_utils.js
pageflow-0.11.3 app/assets/javascripts/pageflow/ui/utils/i18n_utils.js
pageflow-0.11.2 app/assets/javascripts/pageflow/ui/utils/i18n_utils.js
pageflow-0.11.1 app/assets/javascripts/pageflow/ui/utils/i18n_utils.js
pageflow-0.11.0 app/assets/javascripts/pageflow/ui/utils/i18n_utils.js
pageflow-0.10.0 app/assets/javascripts/pageflow/ui/utils/i18n_utils.js
pageflow-0.9.2 app/assets/javascripts/pageflow/ui/utils/i18n_utils.js
pageflow-0.9.1 app/assets/javascripts/pageflow/ui/utils/i18n_utils.js
pageflow-0.9.0 app/assets/javascripts/pageflow/ui/utils/i18n_utils.js