Added regional dialect fallback to generic language (#3)
* Added regional dialect fallback to generic language Signed-off-by: David Martinez <47610359+dvdmrtnz@users.noreply.github.com> * Reorder generic_language to mantain fallback_mapping priority Signed-off-by: David Martinez <47610359+dvdmrtnz@users.noreply.github.com> * Update lib/twine/output_processor.rb Signed-off-by: David Martinez <47610359+dvdmrtnz@users.noreply.github.com> Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com> Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com>
This commit is contained in:
parent
96e0e2c3cd
commit
6cd569fa49
1 changed files with 6 additions and 1 deletions
|
@ -17,7 +17,12 @@ module Twine
|
|||
'zh-TW' => 'zh-Hant' # if we don't have a zh-TW translation, try zh-Hant before en
|
||||
}
|
||||
|
||||
[fallback_mapping[language], default_language].flatten.compact
|
||||
# Regional dialect fallbacks to generic language (for example: 'es-MX' to 'es' instead of default 'en').
|
||||
if language.match(/([a-zA-Z])-[a-zA-Z]+/)
|
||||
generic_language = language.gsub(/([a-zA-Z])-[a-zA-Z]+/, '\1')
|
||||
end
|
||||
|
||||
[fallback_mapping[language], generic_language, default_language].flatten.compact
|
||||
end
|
||||
|
||||
def process(language)
|
||||
|
|
Reference in a new issue