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.

[Feature Request]YAML Locales Support

See original GitHub issue

Is your feature request related to a problem? Please describe.

https://github.com/nuxt-community/i18n-module/blob/master/src/templates/utils.js#L31

            const langFileModule = await import(/* webpackChunkName: "lang-[request]" */ `~/<%= options.langDir %>${file}`)
            const getter = langFileModule.default || langFileModule
            messages = typeof getter === 'function' ? await Promise.resolve(getter(context, locale)) : getter

i found that locales are imported as js/json files. but yaml format files are more lighter.

Describe the solution you’d like

add a check, when pass in yaml files use yaml-parser to load them.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
willincommented, Aug 25, 2020

moreover, if support multiple files will be more better

like:

locales/
en/
  message.yml
  navigation.yml
zh/
  message.yml
  navigation.yml
0reactions
tillsanderscommented, Dec 26, 2021

I can confirm that using the “default” yaml rule breaks i18n blocks. I was able to resolve this by only applying the yaml-loader rule to my locales/ directory, like so:

  build: {
    extend(config) {
      config.module.rules.push({
        test: /locales\/.*\.ya?ml$/,
        type: 'json',
        use: 'yaml-loader'
      })
    }
  }

Now, I can import locales from yaml files in locales/ and still use i18n blocks. I think this or a better solution should be mentioned in the docs. If you like my approach, I can file a PR to add a new guide to the docs. Let me know what you think!

Also, happy holidays!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow explicit exclusion of locales in CLI & its yml file · Issue ...
I'd really appreciate it if I could exclude specific locales from push and pull when using the CLI, at least when pulling. I...
Read more >
Support YAML anchors in the CLI | Cloud Feature Requests ...
The local build tool/CLI/build-agent doesn't support YAML anchors and aliases. This was confirmed by a customer and Lev.
Read more >
[Feature Request] i18n.te doesnt look for global locales -
Not sure if this a bug or a feature, but when I'm trying to check if global translation exists, te returns false for...
Read more >
Descriptor Format of Catalog Entities - Backstage.io
The descriptor format supports substitutions using $text , $json , and $yaml . Placeholders like $json: https://example.com/entity.json are substituted by the ...
Read more >
Issues - GitLab Docs
Discuss the implementation of an idea. Track tasks and work status. Accept feature proposals, questions, support requests, or bug reports. Elaborate on code ......
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