Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fallback formatting #637

Merged
merged 7 commits into from
Aug 12, 2019
Merged

Add fallback formatting #637

merged 7 commits into from
Aug 12, 2019

Conversation

sebwas
Copy link
Contributor

@sebwas sebwas commented Jul 9, 2019

This pull request aims to add formatting of fallback messages if that's desired (it's completely controllable by the i18n options and the default is to turn it off (so that it's 100% backwards compatible))

Turn it on by setting the formatFallbackMessages to true.

The use case is simple: When using the whole string to be translated as key, you will want to format the messages nonetheless:

<div>
  {{ $t('Hello {name}!', { name: 'world' }) }}
</div>

@codecov-io
Copy link

codecov-io commented Jul 9, 2019

Codecov Report

Merging #637 into dev will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##              dev    #637      +/-   ##
=========================================
+ Coverage   96.18%   96.2%   +0.01%     
=========================================
  Files          10      10              
  Lines         787     791       +4     
=========================================
+ Hits          757     761       +4     
  Misses         30      30
Impacted Files Coverage Δ
src/index.js 98.05% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 74a5fd1...bbef25e. Read the comment docs.

@sebwas
Copy link
Contributor Author

sebwas commented Jul 24, 2019

Any comments, @kazupon?

@kazupon
Copy link
Owner

kazupon commented Jul 25, 2019

@sebwas
Sorry, late reply. 🙇

That's a very interesting feature request!
If the specified key cannot be found, it's convenient to interpolate.

We can use that feature for key like message (e.g. This is {name}). We cannot use for key like path. We need to notice to use this feature.
Some documentation updates are required to provide this feature.
Can you update docs? 🙏

src/index.js Outdated

return this._render(key, 'string', parsedArgs.params, key)
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't exactly understand what you mean. Do you mean we should change the wording here, or?

@AlexandreBonaventure
Copy link

Hello what about this issue #296 ? I think this would be worth to reopen, can I submit a PR ?

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.

4 participants