Adding `scope` option to translations
See original GitHub issueFeature request
I would like to be able to do the following in components:
this.$t('message.path', { scope: 'my.very.long.scope.to.the.message' })
// or
const myScope = 'my.very.long.scope.to.the.message'
this.$t('message.path', { scope: myScope })
or even better:
const MyComponent = {
template: `<p v-t="'message.path'"></p>`,
i18n: { scope: myScope }
}
So basically, my goal would be to have my locale messages in one place and provide a socpe
for a component, so that I can type less when translating lots of deeply nested messages.
All I can do now is:
const MyComponent = {
template: `<p v-t="myScope + '.message.path'"></p>`,
data () {
return { myScope = '...' }
},
// and
methods: {
translateMessage (message) { return this.$t(`${this.myScope}.${message}`) }
}
}
But having a scope
option for components would be more elegant (or, at least, less cumbersome…).
Of course, the fallback logic should be considered too.
@kazupon what do you think?
Also, I would be more than happy to try and provide a PR for the feature.
IssueHunt Summary
Backers (Total: $15.00)
Become a backer now!
Or submit a pull request to get the deposits!
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:13 (3 by maintainers)
Top Results From Across the Web
What is "Add a scope" option? - Power Platform Community
Hi Nelena, Scopes are a simple way to group two or more actions together. When you put actions inside a scope they can...
Read more >Scoped Library Extractor | Transloco Angular i18n
The script will extract the translation files from our library and copy them to the main project's translation root folder (e.g., src/assets/i18n )....
Read more >Configure DHCP OPTION 43 for Lightweight Access Points
The Cisco IOS command that is added to the DHCP scope is option 43 hex f108c0a80a05c0a80a14. Click Apply and then click OK. Once...
Read more >Managing Microsoft DHCP Scope and other Components
Learn how to set up everything on a Microsoft DHCP server from scopes, address pools, how DHCP leases work, DHCP reservations and DHCP...
Read more >Configure DHCP Option Records
In the Scope Options dialog box, select the check box for the option record that you created (in this example, 160 IP Phone...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How is this feature coming along?
+1 for scope option SFC i18n custom block is good. But I think the
scope
is also a helpful and practical feature.