question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding `scope` option to translations

See original GitHub issue

Issuehunt badges

Feature 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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:10
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
paulgeislercommented, Dec 12, 2019

How is this feature coming along?

2reactions
vanstekicommented, Oct 8, 2018

+1 for scope option SFC i18n custom block is good. But I think the scope is also a helpful and practical feature.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found