|
@@ -313,40 +313,44 @@ class LangAreaView(TemplateView):
|
|
|
|
|
|
def do_download_SearchTool(self, id, searchtype):
|
|
def do_download_SearchTool(self, id, searchtype):
|
|
content = ''
|
|
content = ''
|
|
- # en_result = self.get_area_language(20)
|
|
|
|
|
|
+ en_result = self.get_area_language(20)
|
|
block_qs = SearchToolBlock.objects.filter(type__contains=searchtype).values('name', 'id')
|
|
block_qs = SearchToolBlock.objects.filter(type__contains=searchtype).values('name', 'id')
|
|
- # skm_qs = SearchToolBlock.objects.filter(type__contains=searchtype).values('name', 'id', "searchtoolkeymodel__lk__id")
|
|
|
|
|
|
+
|
|
|
|
+ skm_qs = SearchToolBlock.objects.filter(type__contains=searchtype).values('name', 'id',
|
|
|
|
+ "searchtoolkeymodel__lk__id")
|
|
if block_qs:
|
|
if block_qs:
|
|
content += '<TS version=\"2.1\" language=\"' + self.get_avss_language(int(id)) + '\">\n'
|
|
content += '<TS version=\"2.1\" language=\"' + self.get_avss_language(int(id)) + '\">\n'
|
|
- # k_list = []
|
|
|
|
- # for k in skm_qs:
|
|
|
|
- # k_list.append(k['searchtoolkeymodel__lk__id'])
|
|
|
|
- # key_qs = LangKeyModel.objects.filter(langvalmodel__la__id=id, id__in=k_list).values('id', 'word_key', 'langvalmodel__word_val')
|
|
|
|
- # loc_qs = LangLocationModel.objects.filter(lk__id__in=k_list).values('id', 'filename', 'line', 'lk__id',
|
|
|
|
- # 'lk__word_key', 'lk__updTime')
|
|
|
|
|
|
+
|
|
|
|
+ k_list = []
|
|
|
|
+ for k in skm_qs:
|
|
|
|
+ k_list.append(k['searchtoolkeymodel__lk__id'])
|
|
|
|
+
|
|
|
|
+ key_qs = LangKeyModel.objects.filter(langvalmodel__la__id=id, id__in=k_list).values('id', 'word_key', 'langvalmodel__word_val')
|
|
|
|
+
|
|
|
|
+ loc_qs = LangLocationModel.objects.filter(lk__id__in=k_list).values('id', 'filename', 'line', 'lk__id',
|
|
|
|
+ 'lk__word_key', 'lk__updTime')
|
|
|
|
|
|
for bk in block_qs:
|
|
for bk in block_qs:
|
|
content += '<context>\n<name>'
|
|
content += '<context>\n<name>'
|
|
content += bk['name']
|
|
content += bk['name']
|
|
content += '</name>\n'
|
|
content += '</name>\n'
|
|
|
|
|
|
- langKey_qs = LangKeyModel.objects.filter(word_key__startswith=bk['name']+'_').values('id', 'word_key', 'langvalmodel__word_val')
|
|
|
|
- langKeyId_list = []
|
|
|
|
- for langKey in langKey_qs:
|
|
|
|
- langKeyId_list.append(langKey['id'])
|
|
|
|
- langLocation_qs = LangLocationModel.objects.filter(lk__id__in=langKeyId_list).values('lk__id', 'filename', 'line')
|
|
|
|
- for langKey in langKey_qs:
|
|
|
|
|
|
+ for lk in key_qs:
|
|
content += '<message>\n'
|
|
content += '<message>\n'
|
|
- for langLocation in langLocation_qs:
|
|
|
|
- if langLocation['lk__id'] == langKey['id']:
|
|
|
|
- if langLocation['line'] != '':
|
|
|
|
- content += '<location filename=\"' + langLocation['filename'] + '\" line=\"' + str(
|
|
|
|
- langLocation['line']) + '\"/>\n'
|
|
|
|
|
|
+ for loc in loc_qs:
|
|
|
|
+ if loc['lk__id'] == lk['id'] :
|
|
|
|
+ if loc['filename'] != '':
|
|
|
|
+ content += '<location filename=\"' + loc['filename'] + '\" line=\"' + str(
|
|
|
|
+ loc['line']) + '\"/>\n'
|
|
|
|
+ word_key = lk['word_key']
|
|
content += '<source>'
|
|
content += '<source>'
|
|
- content += langKey['word_key'][(langKey['word_key'].index('_')+1):] # 截取第一个'_'后面的内容
|
|
|
|
|
|
+ content += word_key[(len(bk['name']) + 1):]
|
|
content += '</source>\n'
|
|
content += '</source>\n'
|
|
content += '<translation>'
|
|
content += '<translation>'
|
|
- translation = langKey['langvalmodel__word_val'] if langKey['langvalmodel__word_val'] is not None else ''
|
|
|
|
|
|
+ translation = lk['langvalmodel__word_val']
|
|
|
|
+ # if translation is None or translation == '':
|
|
|
|
+ # content += '23333'
|
|
|
|
+ # else:
|
|
content += translation
|
|
content += translation
|
|
content += '</translation>\n'
|
|
content += '</translation>\n'
|
|
content += '</message>\n'
|
|
content += '</message>\n'
|