mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-22 23:06:18 +00:00
-now load "pot" files instead of "loc" files for main translation file
This commit is contained in:
parent
868b874505
commit
34e7e822ec
1 changed files with 34 additions and 13 deletions
|
|
@ -18,7 +18,7 @@ class Language
|
||||||
LANG_CK = [
|
LANG_CK = [
|
||||||
'ko', 'zh_CN'
|
'ko', 'zh_CN'
|
||||||
]
|
]
|
||||||
LANGUAGES = Steam.enabled? ? (LANG_WESTERN + LANG_CK + LANG_J) : ['en']
|
LANGUAGES = (LANG_WESTERN + LANG_CK + LANG_J)
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def set(lc)
|
def set(lc)
|
||||||
|
|
@ -27,27 +27,48 @@ class Language
|
||||||
@tr = nil
|
@tr = nil
|
||||||
script = nil
|
script = nil
|
||||||
[lc.full.to_s, lc.lang.to_s].each do |name|
|
[lc.full.to_s, lc.lang.to_s].each do |name|
|
||||||
path = "Languages/#{name}.loc"
|
path = "Languages/#{name}.pot"
|
||||||
dbg_print(path)
|
dbg_print(path)
|
||||||
if FileTest.exist?(path)
|
if FileTest.exist?(path)
|
||||||
File.open(path, "rb") do |file|
|
load_pot(path)
|
||||||
@data = Marshal.load(file)
|
if LANG_CK.include? name
|
||||||
if LANG_CK.include? name
|
Font.default_name = FONT_CK
|
||||||
Font.default_name = FONT_CK
|
elsif LANG_J.include? name
|
||||||
elsif LANG_J.include? name
|
Font.default_name = FONT_J
|
||||||
Font.default_name = FONT_J
|
else
|
||||||
else
|
Font.default_name = FONT_WESTERN
|
||||||
Font.default_name = FONT_WESTERN
|
|
||||||
end
|
|
||||||
Journal.setLang(name)
|
|
||||||
dbg_print(Font.default_name)
|
|
||||||
end
|
end
|
||||||
|
Journal.setLang(name)
|
||||||
|
dbg_print(Font.default_name)
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
reset_fonts(@text_sprites)
|
reset_fonts(@text_sprites)
|
||||||
Oneshot.set_yes_no(tr('Yes'), tr('No'))
|
Oneshot.set_yes_no(tr('Yes'), tr('No'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def load_pot(path)
|
||||||
|
msgid = nil
|
||||||
|
msgstr = nil
|
||||||
|
@data = Hash.new
|
||||||
|
if FileTest.exist?(path)
|
||||||
|
File.readlines(path).each do |line|
|
||||||
|
if line.start_with?("msgid ")
|
||||||
|
line = line[6..-1]
|
||||||
|
#unescape the string
|
||||||
|
eval("msgid = " + line)
|
||||||
|
elsif line.start_with?("msgstr ")
|
||||||
|
line = line[7..-1]
|
||||||
|
#unescape the string
|
||||||
|
eval("msgstr = " + line)
|
||||||
|
if !(msgid.nil? || msgid.empty?)
|
||||||
|
@data[Oneshot::crc32(msgid)] = msgstr
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Translate some text
|
# Translate some text
|
||||||
def tr(string)
|
def tr(string)
|
||||||
#dbg_print(caller_locations(1, 1).first.tap{|loc| puts "#{loc.path}:#{loc.lineno}"})
|
#dbg_print(caller_locations(1, 1).first.tap{|loc| puts "#{loc.path}:#{loc.lineno}"})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue