ikeda commited on
Commit
0ab59c6
1 Parent(s): b8a5709

translate items printed in Japanese into English on Historic Site Card in other languages version

Browse files
Files changed (2) hide show
  1. app.py +1 -0
  2. src/front_card_image_historic_site.py +6 -3
app.py CHANGED
@@ -34,6 +34,7 @@ def create_3dmodel(model_no, title, color, mark, historic_site_type, difficulty,
34
  '訪問難度': difficulty,
35
  '説明文': description,
36
  '厚み': '有' if is_thick else '無',
 
37
  }
38
 
39
  # Consider implementing model_no categorization rules or creating a factory class
 
34
  '訪問難度': difficulty,
35
  '説明文': description,
36
  '厚み': '有' if is_thick else '無',
37
+ 'language': language
38
  }
39
 
40
  # Consider implementing model_no categorization rules or creating a factory class
src/front_card_image_historic_site.py CHANGED
@@ -48,6 +48,7 @@ HS_TYPE_LT_XY = (56, 972)
48
 
49
  # Difficulty of Visit
50
  DIFFICULTY_LT_XY = (444, 972)
 
51
 
52
  # Main Body of Description
53
  DESCRIPTION_LT_XY = (46, 1024)
@@ -114,16 +115,18 @@ def create_historic_site_card_image(img_bytearray, option_dict):
114
  card_imgdraw.text((TITLE_LT_XY[0], int((TITLE_LT_XY[1] + TITLE_RB_XY[1]) / 2)), option_dict['タイトル'], fill='black', font=title_font, anchor='lm')
115
 
116
  # Embedding the Historic Site Type
117
- hs_type_display = f'種類:{option_dict["史跡種類"]}'
118
  hs_typefont = ImageFont.truetype(font_sanselif_path, 40)
119
  card_imgdraw.text(HS_TYPE_LT_XY, hs_type_display, fill='black', font=hs_typefont, anchor='lt')
120
 
121
  # Embedding the Difficulty of Visit
122
  difficulty = int(option_dict['訪問難度'])
123
  difficulty = 1 if difficulty < 1 else 5 if difficulty > 5 else difficulty
124
- difficulty_display = '訪問難度:' + '☆' * difficulty + '' * (5 - difficulty)
 
125
  difficulty_font = ImageFont.truetype(font_sanselif_path, 40)
126
- card_imgdraw.text(DIFFICULTY_LT_XY, difficulty_display, fill='black', font=difficulty_font, anchor='lt')
 
127
 
128
  # Embedding the Description Text
129
  description_font = ImageFont.truetype(font_sanselif_path, 40)
 
48
 
49
  # Difficulty of Visit
50
  DIFFICULTY_LT_XY = (444, 972)
51
+ DIFFICULTY_LT_XY_EN = (424, 972)
52
 
53
  # Main Body of Description
54
  DESCRIPTION_LT_XY = (46, 1024)
 
115
  card_imgdraw.text((TITLE_LT_XY[0], int((TITLE_LT_XY[1] + TITLE_RB_XY[1]) / 2)), option_dict['タイトル'], fill='black', font=title_font, anchor='lm')
116
 
117
  # Embedding the Historic Site Type
118
+ hs_type_display = f'種類:{option_dict["史跡種類"]}' if option_dict["language"] == 'ja' else f'Type: {option_dict["史跡種類"]}'
119
  hs_typefont = ImageFont.truetype(font_sanselif_path, 40)
120
  card_imgdraw.text(HS_TYPE_LT_XY, hs_type_display, fill='black', font=hs_typefont, anchor='lt')
121
 
122
  # Embedding the Difficulty of Visit
123
  difficulty = int(option_dict['訪問難度'])
124
  difficulty = 1 if difficulty < 1 else 5 if difficulty > 5 else difficulty
125
+ difficulty_display = ('訪問難度:' if option_dict["language"] == 'ja' else 'Difficulty: ') \
126
+ + '☆' * difficulty + '★' * (5 - difficulty)
127
  difficulty_font = ImageFont.truetype(font_sanselif_path, 40)
128
+ temp_difficulty_lt_xy = DIFFICULTY_LT_XY if option_dict["language"] == 'ja' else DIFFICULTY_LT_XY_EN
129
+ card_imgdraw.text(temp_difficulty_lt_xy, difficulty_display, fill='black', font=difficulty_font, anchor='lt')
130
 
131
  # Embedding the Description Text
132
  description_font = ImageFont.truetype(font_sanselif_path, 40)