[logaling-commit] logaling/logaling-command [import-tmx] add language code convert method

Back to archive index

null+****@clear***** null+****@clear*****
Fri Apr 27 20:37:50 JST 2012


SUZUKI Miho	2012-04-27 20:37:50 +0900 (Fri, 27 Apr 2012)

  New Revision: 4ab4e51406db621ad5fec237d734f2e7c43a448f

  Log:
    add language code convert method

  Modified files:
    lib/logaling/external_glossaries/tmx.rb

  Modified: lib/logaling/external_glossaries/tmx.rb (+6 -2)
===================================================================
--- lib/logaling/external_glossaries/tmx.rb    2012-04-27 20:30:32 +0900 (02ac5ba)
+++ lib/logaling/external_glossaries/tmx.rb    2012-04-27 20:37:50 +0900 (e128507)
@@ -31,8 +31,7 @@ module Logaling
         notes = []
         tu.children.each do |tuv|
           if tuv.name == "tuv"
-            # logaling using ISO 639 codes (two-letter)
-            lang = tuv["lang"].downcase.sub(/-.*\z/, "")
+            lang = convert_language_code_iso_639(tuv["lang"])
             if lang == glossary_info[:source_language]
               tuv.children.each do |child|
                 original = child.text.strip if child.name == "seg"
@@ -49,5 +48,10 @@ module Logaling
         csv << [original, translation, notes.join(" | ")] if original && translation
       end
     end
+
+    def convert_language_code_iso_639(code)
+      # use two-letter codes
+      code.downcase.sub(/-.*\z/, "")
+    end
   end
 end




More information about the logaling-commit mailing list
Back to archive index