Example #1
0
 def datatable_multi_app(self, content):
     if isinstance(content, dict):
         for key in content:
             line = content[key]
             for s_k in line:
                 if isinstance(line[s_k], str):
                     if line.get('flow_uuid', None):
                         fa = FlowActiveGlobalObject.UUIDSearch(
                             line.get('flow_uuid', None))
                         if fa:
                             app_id = fa.flow_app_id
                         else:
                             app_id = None
                         app_name = None
                     else:
                         app_id = line.get('id', None)
                         app_name = line.get('app_name', None)
                     lan = FlowActiveGlobalObject.getAppLanDict(
                         self.trans_type, app_id,
                         app_name).get(self.language, {})
                     line[s_k] = self.fun(lan.get(line[s_k], line[s_k]),
                                          line[s_k])
     elif isinstance(content, list):
         for line in content:
             for s_k in line:
                 if isinstance(line[s_k], str):
                     if line.get('flow_uuid', None):
                         fa = FlowActiveGlobalObject.UUIDSearch(
                             line.get('flow_uuid', None))
                         if fa:
                             app_id = fa.flow_app_id
                         else:
                             app_id = None
                         app_name = None
                     else:
                         app_id = line.get('id', None)
                         app_name = line.get('app_name', None)
                     lan = FlowActiveGlobalObject.getAppLanDict(
                         self.trans_type, app_id,
                         app_name).get(self.language, {})
                     line[s_k] = self.fun(lan.get(line[s_k], line[s_k]),
                                          line[s_k])
     return content
Example #2
0
 def flowobject(self, content):
     full_language_package = FlowActiveGlobalObject.getAppLanDict(
         self.trans_type, self.app_id, self.app_name)
     lan = full_language_package.get(self.language, {})
     if isinstance(content, str):
         content = json.loads(content)
     items = content['items']
     for i in items:
         item_type = i['type']
         if item_type != 'line':
             #置換元件名稱
             i['text'] = self.fun(lan.get(i['text'], i['text']), i['text'])
     return content
Example #3
0
 def single_app(self, content):
     full_language_package = FlowActiveGlobalObject.getAppLanDict(
         self.trans_type, self.app_id, self.app_name)
     lan = full_language_package.get(self.language, {})
     if isinstance(content, str):
         result = self.fun(lan.get(content, content), content)
     elif isinstance(content, list):
         result = []
         for i in content:
             result.append(self.fun(lan.get(i, i), i))
     elif isinstance(content, dict):
         result = {}
         for key in content:
             result[key] = self.fun(lan.get(content[key], content[key]),
                                    content[key])
     else:
         result = None
     return result
Example #4
0
 def datatable_single_app(self, content):
     full_language_package = FlowActiveGlobalObject.getAppLanDict(
         self.trans_type, self.app_id, self.app_name)
     lan = full_language_package.get(self.language, {})
     if isinstance(content, dict):
         for key in content:
             line = content[key]
             for s_k in line:
                 if isinstance(line[s_k], str):
                     line[s_k] = self.fun(lan.get(line[s_k], line[s_k]),
                                          line[s_k])
     elif isinstance(content, list):
         for line in content:
             for s_k in line:
                 if isinstance(line[s_k], str):
                     line[s_k] = self.fun(lan.get(line[s_k], line[s_k]),
                                          line[s_k])
     return content
Example #5
0
    def formobject(self, content):
        full_language_package = FlowActiveGlobalObject.getAppLanDict(
            self.trans_type, self.app_id, self.app_name)
        lan = full_language_package.get(self.language, {})
        if isinstance(content, str):
            content = json.loads(content)
        items = content['items']
        for i in items:
            item_type = i['type']
            config = i['config']

            if item_type in ['box12', 'box6', 'areabox']:
                config['title'] = self.fun(
                    lan.get(config['title'], config['title']), config['title'])

            elif item_type in [
                    'h_title', 'inputbox', 'date', 'datetime', 'subquery'
            ]:
                config['title'] = self.fun(
                    lan.get(config['title'], config['title']), config['title'])
                config['placeholder'] = self.fun(
                    lan.get(config['placeholder'], config['placeholder']),
                    config['placeholder'])

            elif item_type == 'h_group':
                config['group_title'] = self.fun(
                    lan.get(config['group_title'], config['group_title']),
                    config['group_title'])
                config['user_title'] = self.fun(
                    lan.get(config['user_title'], config['user_title']),
                    config['user_title'])

            elif item_type in ['h_level', 'h_status', 'list', 'checkbox']:
                config['title'] = self.fun(
                    lan.get(config['title'], config['title']), config['title'])
                lists = config['lists']
                for l in lists:
                    l['text'] = self.fun(lan.get(l['text'], l['text']),
                                         l['text'])
        return content