Browse Source

MultiLabel add iscjk

cuu 5 years ago
parent
commit
40cafe09c5
3 changed files with 34 additions and 9 deletions
  1. 12 0
      sys.py/UI/lang_manager.py
  2. 15 2
      sys.py/UI/multilabel.py
  3. 7 7
      sys.py/langs/01_日本語.ini

+ 12 - 0
sys.py/UI/lang_manager.py

@@ -17,6 +17,7 @@ class LangManager(object):
     _Langs = {}
     _Config = None
     _ConfigFileName = "00_English.ini" ## double % to escape 
+    _CJKMode = False
     
     def __init__(self):
         self.Init()
@@ -29,6 +30,17 @@ class LangManager(object):
         self._Langs = {}
         self.SetLangs()
     
+    def IsCJKMode(self):## in MultiLabel, latins seped by white spaces,CJK no needs for that
+        latins = ["English"]
+        self._CJKMode = True
+        
+        for i in latins:
+            if i in self._ConfigFileName:
+                self._CJKMode= False
+                break
+        
+        return self._CJKMode
+        
     def SetLangs(self):
         self._Config = CaseConfigParser()
         #print("SetLangs")

+ 15 - 2
sys.py/UI/multilabel.py

@@ -3,6 +3,7 @@
 import pygame
 
 from skin_manager import MySkinManager
+from lang_manager import MyLangManager
 
 
 class MultiLabel: ##Multi Line Label 
@@ -49,15 +50,27 @@ class MultiLabel: ##Multi Line Label
         self._CanvasHWND = _canvashwnd
 
     def blit_text(self, surface,text, pos, font):
+        iscjk = MyLangManager.IsCJKMode()
+        
         color = self._Color
         words = [word.split(' ') for word in text.splitlines()]
         space = font.size(' ')[0]
+        
+        if iscjk:
+            space = 0
+            words = [list(word.decode("utf8")) for word in text.splitlines()]
+        
         max_width = self._Width
         x ,y = pos
         row_total_width = 0
         lines = 0 
-        for i,line in enumerate(words[:4]):
-            for word in line[:12]:
+        line_max = 12
+        row_max  = 4
+        if iscjk:
+            line_max = line_max*2
+        
+        for i,line in enumerate(words[:row_max]): 
+            for word in line[:line_max]:
                 word_surface = font.render(word, True, color)
                 word_width = word_surface.get_width()
                 word_height = word_surface.get_height()

+ 7 - 7
sys.py/langs/01_日本語.ini

@@ -26,23 +26,23 @@ AddFav=お気に入りに追加
 ADdFavList=お気に入りリストに登録
 Del=削除
 Please upload data over Wi-Fi=Wi-Fiでデータを送信してください
-ConfirmDeleteQ=削除しますか
+ConfirmDeleteQ=削除しますか?
 AlreadyExisted=既に存在している
 Cancel=取り消す
 Yes=はい
 ConfirmQ=確認?
 Disconnecting=接続を切断
-ConfirmUpdateToFQ=%%sにアップデートしますか
-UpdateToFQ=%%sにアップデート
-SetupGameEngineAutoQ=ゲームエンジンの自動セットアップを希望しますか
+ConfirmUpdateToFQ=%%sにアップデートしますか?
+UpdateToFQ=%%sにアップデート?
+SetupGameEngineAutoQ=ゲームエンジンの自動セットアップを希望しますか?
 Downloading=ダウンロード中
 BATOver5Pct=バッテリーは5%%以上が必要
 DeleteConfirm=削除の確認
 FavouriteGames=お気に入りのゲーム
-ConfirmForgetQ=無視しますか
+ConfirmForgetQ=無視しますか?
 ConfirmForget=無視しますか
 Disconnect=接続を切断
-ConfirmDisconnectQ=接続を切りますか
+ConfirmDisconnectQ=接続を切りますか?
 Confirm Disconnect=接続を切りますか
 Forget=無視
 Forgeting=無視中
@@ -100,7 +100,7 @@ Power saving=省エネルギー
 Balanced=バランス
 Server=サーバ
 Performance=性能
-Confirm Power OFF?=電源オフしますか
+Confirm Power OFF?=電源オフしますか?
 Reboot=再起動
 Shutdown=シャットダウン
 Play List=プレイリスト