|
@@ -113,6 +113,7 @@ class LangAreaView(TemplateView):
|
|
|
return response.json(0, list(la_qs))
|
|
|
|
|
|
def do_export(self, request_dict, response, userID):
|
|
|
+ print("进来了")
|
|
|
id = request_dict.get('id', None)
|
|
|
type = request_dict.get('type', None)
|
|
|
# key_list = LangKeyModel.objects.filter().values_list('word_key', flat=True)
|
|
@@ -133,7 +134,8 @@ class LangAreaView(TemplateView):
|
|
|
elif en_kv[r['word_key']]:
|
|
|
res[r['word_key']] = en_kv[r['word_key']]
|
|
|
for l in res:
|
|
|
- content = content + '"' + l + '"="' + res[l] + '";\n'
|
|
|
+ content_val = res[l].replace('"', '\'')
|
|
|
+ content = content + '"' + l + '"="' + content_val + '";\n'
|
|
|
elif type == 'android':
|
|
|
res_qs = LangKeyModel.objects.filter(langvalmodel__la__id=id).\
|
|
|
values('word_key', 'langvalmodel__word_val').order_by('addTime')
|
|
@@ -148,7 +150,8 @@ class LangAreaView(TemplateView):
|
|
|
lk = l
|
|
|
lk = lk.replace('.', '_')
|
|
|
lk = lk.replace('\\n', '_')
|
|
|
-
|
|
|
+ lk = lk.replace('“', '_')
|
|
|
+ lk = lk.replace('”', '_')
|
|
|
lk = lk.replace(' ', '_')
|
|
|
lk = lk.replace('\\\'', '_')
|
|
|
lk = lk.replace('\'', '_')
|
|
@@ -169,7 +172,8 @@ class LangAreaView(TemplateView):
|
|
|
lk = lk.replace('‘', '_')
|
|
|
# 正则表达式
|
|
|
# re.sub("[a-z]+", "$", "123abc78ab9cdeg00t8")
|
|
|
- content = content + '<string name="' + lk + '">' + res[l] + '</string>\n'
|
|
|
+ content_val = res[l].replace("'","\\'")
|
|
|
+ content = content + '<string name="' + lk + '">' + content_val + '</string>\n'
|
|
|
response = StreamingHttpResponse(content)
|
|
|
response['Content-Type'] = 'application/octet-stream'
|
|
|
response['Content-Disposition'] = 'attachment;filename="lang.txt"'
|
|
@@ -193,7 +197,6 @@ class exportLangView(TemplateView):
|
|
|
|
|
|
def validate(self, request_dict):
|
|
|
# 得到即将下载文件的路径和名称
|
|
|
-
|
|
|
response = StreamingHttpResponse('123l4kjlkfjlksadjlfksdajlf')
|
|
|
response['Content-Type'] = 'application/octet-stream'
|
|
|
response['Content-Disposition'] = 'attachment;filename="lang.txt"'
|