11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.

Home Page:https://www.11ty.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support to ISO-639-3 language codes

futurespy opened this issue · comments

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

The new I18n feature only supports languages listed on ISO-639-1. ISO-639-3 codes are simply ignored, but some languages are only listed in the 3rd standard. Consequently, post.url | locale_links doesn't return the link to the content in these unlisted languages.

Describe the solution you'd like

A quick dirty fix would be adding:

const languagesByIso6393Code = require('wikidata-lang/indexes/by_iso_639_3_code')

...

if (!iso639.validate(s) && !languagesByIso6393Code[code]) {
return false;
}

...

   filemap[replaced].push({
     url,
     lang: langCode,
     **label: (iso639.getNativeName(langCode.split("-")[0]) ? iso639.getNativeName(langCode.split("-")[0]) : (languagesByIso6393Code[langCode][0]['native'] ? languagesByIso6393Code[langCode][0]['native'] : languagesByIso6393Code[langCode][0]['label'])),**
   });

Describe alternatives you've considered

Is there anyway I could override the plugin in my Eleventy installation?

Additional context

No response