Skip to content

Commit

Permalink
deprecated zh-cn and zh-hk locales, normalized as zh-CN and zh-HK
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Mar 28, 2019
1 parent c28d21a commit 6b7fe77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lib/locales/utils/loader.rb
Expand Up @@ -16,10 +16,17 @@
end
end

normalized_locales = {'zh-cn'=>'zh-CN', 'zh-hk'=>'zh-HK'}

# loader proc
lambda do |i18n, *args|
i18n.clear
args.each do |arg|
if normalized_locales.keys.include?(arg[:locale])
right_locale = normalized_locales[arg[:locale]]
Warning.warn("\n*** WARNING *** [Pagy::I18n] The '#{arg[:locale]}' locale is incorrect and deprecated, please use '#{right_locale}'\n\n")
arg[:locale] = right_locale
end
arg[:filepath] ||= Pagy.root.join('locales', "#{arg[:locale]}.yml")
arg[:pluralize] ||= p11n[arg[:locale]]
hash = YAML.load(File.read(arg[:filepath], encoding: 'UTF-8')) #rubocop:disable Security/YAMLLoad
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/zh-cn.yml → lib/locales/zh-CN.yml
@@ -1,4 +1,4 @@
zh-cn:
zh-CN:
pagy:
nav:
prev: "‹ 上一页"
Expand Down
4 changes: 2 additions & 2 deletions lib/locales/zh-hk.yml → lib/locales/zh-HK.yml
@@ -1,4 +1,4 @@
zh-hk:
zh-HK:
pagy:
nav:
prev: "‹ 上一頁"
Expand All @@ -17,4 +17,4 @@ zh-hk:
compact: "第 %{page_input} / %{pages} 頁"
items:
one: "每頁顯示 %{items_input} 記錄"
other: "每頁顯示 %{items_input} 記錄"
other: "每頁顯示 %{items_input} 記錄"

0 comments on commit 6b7fe77

Please sign in to comment.