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

internationalization needed on description #553

Open
flozero opened this issue Aug 12, 2019 · 15 comments · May be fixed by #710
Open

internationalization needed on description #553

flozero opened this issue Aug 12, 2019 · 15 comments · May be fixed by #710
Labels
enhancement New feature or request intend to implement Sometime in the next 2 major release this will be implemented request for comments

Comments

@flozero
Copy link
Member

flozero commented Aug 12, 2019

The problem

actually as the doc is never in one lang you should be able to I18n components easily

Proposed solution

Create subfolder for i18n. and parse description and create as many files as you have trads

Alternative solutions

none

Additional context

@elevatebart elevatebart added vue-docgen-cli bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Aug 12, 2019
@elevatebart
Copy link
Member

elevatebart commented Aug 12, 2019

I see three parts in this enhancement

  • allowing vue-docgen-cli to load descriptions in a different locale than the native one to replace the descriptions of the docgen object
  • allowing vue-docgen-cli to generate this locale description file automatically:
    structure of the locale file
    button.FR.json
{
  "props": {
    "color": {
      "master": "the color for the button",
      "i18n": "la couleur du bouton"
    }
  }
}
  • having a tool that checks updates this locale object each time the component is updated and helps documenters clearly see non-translated descriptions. If a description does not correspond, the translation is removed and the description is removed.

@elevatebart
Copy link
Member

I would host the locales files near the component files.
src/components/button.vue would have src/components/button.doc.FR.json for translations in french

@Jesus82
Copy link

Jesus82 commented Aug 13, 2019

I'd ask to leave the option to have all the translations in a separate file, in a "locales" folder (and not based in components). The reason is that many components may share the same translation keys.

@elevatebart
Copy link
Member

Hello @Jesus82,

This is an interesting suggestion.

How would you organize the file in this case?
Would you have a flat list of strings to translate?
What would be the keys to access those translations?

Keep in mind that, in order to keep context, and jsdoc response active, the main idea is to keep the English doc in the components themselves.

Thank you

@Jesus82
Copy link

Jesus82 commented Aug 13, 2019

I have it organized a little bit different, with the locales folder at the same level with the components folder, and then a file for each language. That's also how I'm planning to use my components later, if fx I want to place it in a nuxt app (with a separate file, one for each language).

@elevatebart
Copy link
Member

elevatebart commented Aug 13, 2019

This folder structure this is what I understand from your description.
It feels a little harder to navigate but easier to extract a whole folder to send for translations.

src
 └─components
      ├─Button
      |     ├─Button.vue
      |     └─Readme.md
      ├─Input
      |     ├─Input.vue
      |     └─Readme.md
      └─Locales
            └─FR
                 ├─Button
                 |     ├─Readme.md
                 |     └─descriptions.json
                 └─Input
                       ├─Readme.md
                       └─descriptions.json

Did I get your scaffolding right? Did you have other suggestions?

@flozero
Copy link
Member Author

flozero commented Aug 13, 2019

if think it's something like this yeah but not locale, use locales. Why readme in locales ? @elevatebart

@elevatebart
Copy link
Member

Since the readme contains the documentation that will occupy the bottom of the component sheet, it could be useful to translate it as well. It might be a challenge to know when the file is obsolete.

My first reaction would be to use markdown comments at the end of the file. This would serve as the key for the last updated original file.

[//]: # <automatically generated code> docgen.hash = fr5tfdc3efg765hbvt

When asked to check translations, we could provide the diff of the original Readme.md since the last change. In case of mismatch, we would ask users to confirm that translation is still correct.

@Jesus82
Copy link

Jesus82 commented Aug 14, 2019

I was thinking more in something like this (as it mimics how I would set the translations IRL). While in CSS it can make sense to have separate CSS's for each component, and then have some common styles, in translations I prefer to have just a file and then have subobjects for each part of the web, so I can scan all terms at the same time and see if there is something that is already translated.

It is also how nuxt structure works.

src
 |─components
 |   ├─Button
 |   |     ├─Button.vue
 |   |     └─Readme.md
 |   ├─Input
 |   |     ├─Input.vue
 |   |     └─Readme.md
 └─Local
     └─FR.json
     └─ES.json

@elevatebart
Copy link
Member

elevatebart commented Aug 14, 2019 via email

@Jesus82
Copy link

Jesus82 commented Aug 16, 2019

Yep, I would do it that way (assigning a translation key to each of the markdown texts).

@elevatebart
Copy link
Member

@Jesus82 since JSON does not accept multi-line text how would you go about this translation?
String arrays? How would you choose the keys of each part of the markdown?

As of now it very much seems an awful lot of work just for not repeating code.

@elevatebart elevatebart added this to To do in Version 4 via automation Nov 1, 2019
@elevatebart elevatebart moved this from To do to Done in Version 4 Nov 15, 2019
@elevatebart elevatebart removed this from Done in Version 4 Nov 15, 2019
@elevatebart elevatebart added the intend to implement Sometime in the next 2 major release this will be implemented label Nov 21, 2019
@elevatebart elevatebart linked a pull request Jan 14, 2020 that will close this issue
3 tasks
@elevatebart elevatebart added this to To Do in vue-docgen-cli Jan 28, 2020
@vanpipy
Copy link

vanpipy commented Oct 13, 2022

Hi, any update here? I saw the PR, and it stuck the deps?

@elevatebart
Copy link
Member

No update for now as I have had very little time to work on open source recently.

If you feel like taking it on, I can be available for support.

If not, It might take a few more months before I get back to it.

Sorry.

@vanpipy
Copy link

vanpipy commented Oct 13, 2022

No update for now as I have had very little time to work on open source recently.

If you feel like taking it on, I can be available for support.

If not, It might take a few more months before I get back to it.

Sorry.

Never mind and thanks for your work. I want the internationalization function of the vue-styleguidist and found this PR. It is a long time and I spent little time to figure out why but lots of detail I did not know, so I ask here. Thanks for your quick reply. I wound do something I can for it :D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request intend to implement Sometime in the next 2 major release this will be implemented request for comments
Projects
vue-docgen-cli
  
To Do
Development

Successfully merging a pull request may close this issue.

4 participants