Skip to content

Commit f18e76d

Browse files
committed
CoderDojo タグ分布チャートの英語対応を実装
- タグ翻訳用のヘルパーメソッド translate_dojo_tag を追加 - よく使われるタグの英語訳辞書を作成(30以上のタグに対応) - StatsController でタグ名を言語に応じて動的に翻訳 - グラフ内の凡例「対応道場数」も英語化
1 parent f72ea3f commit f18e76d

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

app/controllers/stats_controller.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@ def show
4141
end
4242
tags = tags.sort_by{|key, value| value}.reverse.to_h
4343

44-
f.xAxis categories: tags.keys.take(number_of_tags).reverse
44+
# タグ名を言語に応じて翻訳
45+
tag_labels = if @lang == 'en'
46+
tags.keys.take(number_of_tags).map { |tag| helpers.translate_dojo_tag(tag) }.reverse
47+
else
48+
tags.keys.take(number_of_tags).reverse
49+
end
50+
51+
f.xAxis categories: tag_labels
4552
f.yAxis title: { text: '' }, showInLegend: false, opposite: true,
4653
tickInterval: 40, max: 240
47-
f.series type: 'column', name: "対応道場数", yAxis: 0, showInLegend: false,
54+
f.series type: 'column', name: @lang == 'en' ? "Number of Dojos" : "対応道場数", yAxis: 0, showInLegend: false,
4855
data: tags.values.take(number_of_tags).reverse,
4956
dataLabels: {
5057
enabled: true,

app/helpers/application_helper.rb

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,55 @@ def prefecture_name_in_english(prefecture_name)
150150
prefecture_names[prefecture_name] || prefecture_name
151151
end
152152

153+
def translate_dojo_tag(tag_name)
154+
# よくあるCoderDojoタグの英語訳
155+
tag_translations = {
156+
'ボードゲーム' => 'Board Games',
157+
'ロボット' => 'Robotics',
158+
'マインクラフト' => 'Minecraft',
159+
'タイピング' => 'Typing',
160+
'電子工作' => 'Electronics',
161+
'プログラミング' => 'Programming',
162+
'ゲーム' => 'Gaming',
163+
'パソコン' => 'Computers',
164+
'初心者歓迎' => 'Beginners Welcome',
165+
'オンライン開催あり' => 'Online Available',
166+
'オンライン' => 'Online',
167+
'女子' => 'Girls',
168+
'中高生' => 'Teens',
169+
'3Dプリンター' => '3D Printing',
170+
'AI' => 'AI',
171+
'IoT' => 'IoT',
172+
'VR' => 'VR',
173+
'AR' => 'AR',
174+
'Web' => 'Web',
175+
'アプリ' => 'Apps',
176+
'デザイン' => 'Design',
177+
'音楽' => 'Music',
178+
'動画' => 'Video',
179+
'アニメーション' => 'Animation',
180+
'ドローン' => 'Drones',
181+
'レゴ' => 'LEGO',
182+
'工作' => 'Crafts',
183+
'ラズベリーパイ' => 'Raspberry Pi',
184+
'Webサイト' => 'Web Development',
185+
'ウェブサイト' => 'Web Development',
186+
'スクラッチ' => 'Scratch',
187+
'Scratch' => 'Scratch',
188+
'Python' => 'Python',
189+
'JavaScript' => 'JavaScript',
190+
'Ruby' => 'Ruby',
191+
'Unity' => 'Unity',
192+
'micro:bit' => 'micro:bit',
193+
'マイクロビット' => 'micro:bit',
194+
'レーザーカッター' => 'Laser Cutting',
195+
'ビスケット' => 'Viscuit',
196+
'Viscuit' => 'Viscuit',
197+
'HTML' => 'HTML',
198+
'CSS' => 'CSS'
199+
}
200+
201+
tag_translations[tag_name] || tag_name
202+
end
203+
153204
end

0 commit comments

Comments
 (0)