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

Question: How to translate tags? #592

Open
jcristovao opened this issue Oct 16, 2015 · 2 comments
Open

Question: How to translate tags? #592

jcristovao opened this issue Oct 16, 2015 · 2 comments

Comments

@jcristovao
Copy link

Is it possible to translate tags, meaning, having two different tags regarding the same concept:

  • photography (EN)
  • fotografia (PT)

But when using the i18n_subsites plugin, changing the address from /pt/... to /en/... having it do the tag translation?

Thanks

@andreubotella
Copy link

andreubotella commented Feb 18, 2018

Here's a bit of a hackish way to do it for categories and tags:

Add something like this to your pelicanconf.py (use TAG_SUBSTITUTIONS for tags):

CATEGORY_SUBSTITUTIONS = [
   ("fotografía", "photography", True),
   ("撮影", "photography", True),
   ("desarrollo de software", "software development", True),
   ("ソフトウェアー開発", "software development", True)
]

And then add the categories to I18N_SUBSITES:

I18N_SUBSITES = {
   "es": {
      "CATEGORY_SUBSTITUTIONS": [
         ("photography", "fotografía", True),
         ("撮影", "fotografía", True),
         ("software development", "desarrollo de software", True),
         ("ソフトウェアー開発", "desarrollo de software", True)
      ]
   },
   "jp": {
      "CATEGORY_SUBSTITUTIONS": [
         ("photography", "撮影", True),
         ("fotografía", "撮影", True),
         ("software development", "ソフトウェアー開発", True),
         ("desarrollo de software", "ソフトウェアー開発", True)
      ]
   }
}

It's basically treating the category/tag names for other languages as aliases for the current language's. See SLUG_SUBSTITUTIONS, CATEGORY_SUBSTITUTIONS and TAG_SUBSTITUTIONS in the Pelican settings documentation.

I guess this could very well be a plugin on itself, with a single setting that defined once the different names in each language and then added the substitutions.

@justinmayer
Copy link
Member

@andreubotella: Would you be interested in working on such a plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants