Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mweibel
Copy link

@mweibel mweibel commented Mar 21, 2016

When using a key which is not found, IMHO we should return the full path instead of just the last part of the iteration. This makes it possible to use a fallback if the passed key is the same as the returned key.

Though: I guess you had a reason why you returned just the last key. Should we maybe instead add an optional fallback argument?

When using a key which is not found, IMHO we should return the full path instead of just the last part of the iteration. This makes it possible to use a fallback if the passed key is the same as the returned key.
@alexkuz
Copy link
Owner

alexkuz commented Mar 21, 2016

It's just so the page wouldn't seem messy if langpack value is not defined yet (or langpack was not loaded or something).
I think it's better to have an optional notFoundCallback, by default - (locale, path) => path[path.length - 1]. I guess i18n should be a factory that receives options argument:

const DEFAULT_OPTIONS = {
  notFoundCallback: ...
};

export default function i18n(options) {
  options = { ...DEFAULT_OPTIONS, ...options };

  return (state = DEFAULT_STATE, action) => {
    return (action.type === LOAD_LANG_SUCCESS) ?
      mergeLang(state, action, options) :
      state;
  }
}

and then pass it to i18nResolver, something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants