Example #1
0
    def __CreateAndroidXmlOutputNode(self, outputs_node, locale, xml_res_dir):
        """Creates the <output> element corresponding to various rc file output."""
        # Need to check to see if the locale has a region, e.g. the GB in en-GB.
        # When a locale has a region Android expects the region to be prefixed
        # with an 'r'. For example for en-GB Android expects a values-en-rGB
        # directory.  Also, Android expects nb, tl, in, iw, ji as the language
        # codes for Norwegian, Tagalog/Filipino, Indonesian, Hebrew, and Yiddish:
        # http://developer.android.com/reference/java/util/Locale.html
        if locale == 'es-419':
            android_locale = 'es-rUS'
        else:
            android_lang, dash, region = locale.partition('-')
            lang_map = {
                'no': 'nb',
                'fil': 'tl',
                'id': 'in',
                'he': 'iw',
                'yi': 'ji'
            }
            android_lang = lang_map.get(android_lang, android_lang)
            android_locale = android_lang + ('-r' + region if region else '')
        values = 'values-' + android_locale if android_locale != 'en' else 'values'
        xml_path = os.path.normpath(
            os.path.join(xml_res_dir, values, 'strings.xml'))

        node = node_io.OutputNode()
        node.StartParsing(u'output', outputs_node)
        node.HandleAttribute('filename', xml_path)
        node.HandleAttribute('lang', locale)
        node.HandleAttribute('type', 'android')
        node.EndParsing()
        outputs_node.AddChild(node)
        return node
Example #2
0
 def __CreateRcOutputNode(self, outputs_node, lang, rc_dir):
     """Creates the <output> element corresponding to various rc file output."""
     rc_file_name = self.name + '_' + lang + ".rc"
     rc_path = os.path.join(rc_dir, rc_file_name)
     node = node_io.OutputNode()
     node.StartParsing(u'output', outputs_node)
     node.HandleAttribute('filename', rc_path)
     node.HandleAttribute('lang', lang)
     node.HandleAttribute('type', 'rc_all')
     node.EndParsing()
     outputs_node.AddChild(node)
     return node
Example #3
0
 def __CreateCppHeaderOutputNode(self, outputs_node, header_dir):
     """Creates the <output> element corresponding to the generated c header."""
     header_file_name = os.path.join(header_dir, self.name + '.h')
     header_node = node_io.OutputNode()
     header_node.StartParsing(u'output', outputs_node)
     header_node.HandleAttribute('filename', header_file_name)
     header_node.HandleAttribute('type', 'rc_header')
     emit_node = node_io.EmitNode()
     emit_node.StartParsing(u'emit', header_node)
     emit_node.HandleAttribute('emit_type', 'prepend')
     emit_node.EndParsing()
     header_node.AddChild(emit_node)
     header_node.EndParsing()
     outputs_node.AddChild(header_node)
     return header_node