content icon indicating copy to clipboard operation
content copied to clipboard

feat: add i18n support

Open NftTopBest opened this issue 2 years ago • 26 comments

🔗 Linked issue

i18n feature issue item from docus: https://github.com/nuxt-themes/docus/issues/770

❓ Type of change

  • [x] 📖 Documentation (updates to the documentation or readme)
  • [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ ] 👌 Enhancement (improving an existing functionality like performance)
  • [x] ✨ New feature (a non-breaking change that adds functionality)
  • [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

The PR adds i18n features. The idea comes from here: https://github.com/nuxt-themes/docus/issues/770 After some more deep digs, I find out the solution is to make a PR here. And nothing to do with the docus project.

Screenshot 2023-05-21 at 21 39 49

  • [x] Add playground/i18n example
  • [x] Add dev:i18n command in package.json

📝 Checklist

  • [x] I have linked an issue or discussion.
  • [x] I have updated the documentation accordingly.

NftTopBest avatar May 21 '23 13:05 NftTopBest

Live Preview ready!

Name Edit Preview Latest Commit
content Edit on Studio ↗︎ View Live Preview 2fa859d1c4b19374f75ca060970d267bc85377f9

nuxt-studio[bot] avatar May 21 '23 13:05 nuxt-studio[bot]

Live Preview ready!

Name Edit Preview Latest Commit
content Edit on Studio ↗︎ View Live Preview 564d21ea9090e6a18eb8a3153575c865681b62de

nuxt-studio[bot] avatar May 21 '23 13:05 nuxt-studio[bot]

Deploy Preview for nuxt-content canceled.

Built without sensitive environment variables

Name Link
Latest commit 2fa859d1c4b19374f75ca060970d267bc85377f9
Latest deploy log https://app.netlify.com/sites/nuxt-content/deploys/646b5c3abf9e7c00081cad85

netlify[bot] avatar May 21 '23 13:05 netlify[bot]

@farnabaz @Atinux ;

This looks reasonable, I briefly checked the code and it seem to only be built for Document Driven mode.

As I think this behavior can easily be achieved via regular prefixed content queries, what do you think in including this in Document Driven mode?

We could also move that code somewhere in Docus I guess.

Tahul avatar May 22 '23 08:05 Tahul

I don't think useI18n() is the correct name, I would at least name it useContentI18n() to avoid conflict with other libraries.

Before changing the document driven mode, I believe we need first to have an upgrade of it to avoid using a middleware but a plugin to inject the page to vue-router itself, this way we can leverage payload extraction as well as better i18n support.

atinux avatar May 22 '23 08:05 atinux

We could also move that code somewhere in Docus I guess.

This is why we can not make it in Docus.

  1. At the beginning, I try to make it in Docus, then find out that I have to update the code here
  2. And finally all the code setup in Content is enough, no more code for Docus then.
  3. And only changing the code in Docus can not have the ability to update the navigation update to a new lang, check the code here: https://github.com/nuxt/content/pull/2075/files#diff-655e26ed4032bc6928b3b3838a699902e421b1838fadf34ed6d78decdfdfa69dR52-R64

The target features:

  1. user can have a lang switcher to switch to multiple langs with the top and sidebar nav change correspond
  2. user just simply setup the locales and defaultLocale in the nuxt.config.ts to turn on the feature in Docus or any other nuxt app that use the Content, there is no need to install the nuxt-i18n module
  3. nuxt-i18n module maybe not suit for this as it seems auto-generate new lang route for every lang, and in the content case

Just add an online demo here: https://nuxt-content-i18n.vercel.app/, pls check the result @Tahul @Atinux

NftTopBest avatar May 22 '23 11:05 NftTopBest

This issue is extremely important to me, I hope it will be resolved for a moment. Thank you @NftTopBest pr.

productdevbook avatar Jun 06 '23 04:06 productdevbook

This issue is extremely important to me, I hope it will be resolved for a moment. Thank you @NftTopBest pr.

@Tahul @Atinux Is that I need another update to make this PR works?

NftTopBest avatar Jun 06 '23 08:06 NftTopBest

Any progress?

truesteps avatar Jun 06 '23 09:06 truesteps

@truesteps

Check out the demo here: https://nuxt-content-i18n.vercel.app/

For now, I am not sure what I should do further.

NftTopBest avatar Jun 07 '23 04:06 NftTopBest

@NftTopBest I love the implementation, I meant any progress on the maintainers side :) thanks for the quick work, it looks amazing

truesteps avatar Jun 07 '23 07:06 truesteps

I'd like to use that soon.

XenBG avatar Jun 16 '23 07:06 XenBG

Whooo, awesome. Thanks for this! Can't wait to try it in my portfolio because it's currently written in French but many wants to read it in English.

Barbapapazes avatar Jul 03 '23 17:07 Barbapapazes

Hi @farnabaz , is there anything I need to modify for the code?

NftTopBest avatar Jul 04 '23 08:07 NftTopBest

Before changing the document driven mode, I believe we need first to have an upgrade of it to avoid using a middleware but a plugin to inject the page to vue-router itself, this way we can leverage payload extraction as well as better i18n support.

Hello @Atinux, could you explain more "inject the page to vue-router"? Thanks.

Barbapapazes avatar Jul 04 '23 09:07 Barbapapazes

Hi @farnabaz , is there anything I need to modify for the code?

Hello, I think that the support for i18n could also be add for non DocumentDriven mode. Using ContentDoc, ContentFetch and ContentNavigation.

Barbapapazes avatar Jul 04 '23 09:07 Barbapapazes

Hello, maintainers. May I inquire if there have been any recent updates regarding the timeline for merging this feature?

XeniaLu avatar Aug 18 '23 06:08 XeniaLu

Hi ! Thanks a lot for this PR, I hope it will be added to this project soon ! Can we do anything to help things going forward ? @farnabaz ?

arkhaiel avatar Sep 05 '23 12:09 arkhaiel

Any progress on this?

narr07 avatar Jun 07 '24 18:06 narr07

Any progress on this? x2

mthmcalixto avatar Jul 02 '24 07:07 mthmcalixto