Exemplo n.º 1
0
    def localize(self, translation):
        """Return localized version of model"""
        
        model = copy.deepcopy(self)
        
        if type(translation) == str or type(translation) == unicode:
            translation = self.translations[translation]
            
        if "locale" not in translation:
            raise ValueError("No locale specified in model translation")
    
        model.locale = translation["locale"]
        util.localize_common(model, translation)
            
        if "cubes" in translation:
            for name, cube_trans in translation["cubes"].items():
                cube = model.cube(name)
                cube.localize(cube_trans)
                
        if "dimensions" in translation:
            for name, dim_trans in translation["dimensions"].items():
                dim = model.dimension(name)
                dim.localize(dim_trans)

        return model
Exemplo n.º 2
0
 def localize(self, locale):
     util.localize_common(self,locale)
     
     attr_locales = locale.get("attributes")
     if attr_locales:
         for attrib in self.attributes:
             if attrib.name in attr_locales:
                 util.localize_common(attrib, attr_locales[attrib.name])
Exemplo n.º 3
0
    def localize(self, locale):
        util.localize_common(self, locale)

        level_locales = locale.get("levels")
        if level_locales:
            for level in self.levels:
                level_locale = level_locales.get(level.name)
                level.localize(level_locale)

        hier_locales = locale.get("hierarcies")
        if hier_locales:
            for hier in self.hierarchies:
                hier_locale = hier_locales.get(hier.name)
                hier.localize(hier_locale)
Exemplo n.º 4
0
    def localize(self, locale):
        util.localize_common(self,locale)
        
        attr_locales = locale.get("measures")
        if attr_locales:
            for attrib in self.measures:
                if attrib.name in attr_locales:
                    util.localize_common(attrib, attr_locales[attrib.name])

        attr_locales = locale.get("details")
        if attr_locales:
            for attrib in self.details:
                if attrib.name in attr_locales:
                    util.localize_common(attrib, attr_locales[attrib.name])
Exemplo n.º 5
0
 def localize(self, locale):
     util.localize_common(self,locale)