Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openshot
Openshot Qt
提交
b2527b31
O
Openshot Qt
项目概览
openshot
/
Openshot Qt
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Openshot Qt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b2527b31
编写于
3月 10, 2014
作者:
J
Jonathan Thomas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved translation loading to have clear debug output to help the user determine any issues.
上级
c34ff540
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
16 deletion
+35
-16
src/classes/language.py
src/classes/language.py
+35
-16
未找到文件。
src/classes/language.py
浏览文件 @
b2527b31
...
...
@@ -34,10 +34,10 @@ from classes import info
def
init_language
():
""" Find the current locale, and install the correct translators """
#Get app instance
#
Get app instance
app
=
QCoreApplication
.
instance
()
#Setup of our list of translators and paths
#
Setup of our list of translators and paths
translator_types
=
(
{
"type"
:
'QT'
,
"pattern"
:
'qt_%s'
,
...
...
@@ -47,21 +47,38 @@ def init_language():
"path"
:
os
.
path
.
join
(
info
.
PATH
,
'locale'
)},
)
#Determine the environment locale, or default to system locale name
log
.
info
(
QLocale
().
system
().
uiLanguages
())
locale_name
=
os
.
environ
.
get
(
'LANG'
,
QLocale
().
system
().
name
())
# Determine the environment locale, or default to system locale name
locale_names
=
[
os
.
environ
.
get
(
'LANG'
,
QLocale
().
system
().
name
()),
os
.
environ
.
get
(
'LOCALE'
,
QLocale
().
system
().
name
())
]
#Don't try on default locale, since it fails to load what is the default language
if
locale_name
==
'en_US'
:
return
#Go through each translator and try to add for current locale
for
type
in
translator_types
:
trans
=
QTranslator
(
app
)
if
not
find_language_match
(
type
[
"pattern"
],
type
[
"path"
],
trans
,
locale_name
):
log
.
warn
(
type
[
"type"
]
+
" translations failed to load"
)
else
:
app
.
installTranslator
(
trans
)
# Output all system languages detected
log
.
info
(
"Qt Detected Languages: %s"
%
QLocale
().
system
().
uiLanguages
())
log
.
info
(
"LANG Environment Variable: %s"
%
os
.
environ
.
get
(
'LANG'
,
QLocale
().
system
().
name
()))
log
.
info
(
"LOCALE Environment Variable: %s"
%
os
.
environ
.
get
(
'LOCALE'
,
QLocale
().
system
().
name
()))
# Loop through environment variables
found_language
=
False
for
locale_name
in
locale_names
:
# Don't try on default locale, since it fails to load what is the default language
if
'en_US'
in
locale_name
:
log
.
info
(
"Skipping English language (no need for translation): %s"
%
locale_name
)
continue
# Go through each translator and try to add for current locale
for
type
in
translator_types
:
trans
=
QTranslator
(
app
)
if
find_language_match
(
type
[
"pattern"
],
type
[
"path"
],
trans
,
locale_name
):
# Install translation
app
.
installTranslator
(
trans
)
found_language
=
True
# Exit if found language
if
found_language
:
log
.
info
(
"Exiting translation system (since we successfully loaded: %s)"
%
locale_name
)
break
# Try the full locale and base locale trying to find a valid path
# returns True when a match was found.
...
...
@@ -79,6 +96,8 @@ def find_language_match(pattern, path, translator, locale_name):
formatted_name
=
pattern
%
"_"
.
join
(
locale_parts
[:
i
])
log
.
info
(
'Attempting to load %s in
\'
%s
\'
'
%
(
formatted_name
,
path
))
success
=
translator
.
load
(
formatted_name
,
path
)
if
success
:
log
.
info
(
'Successfully loaded %s in
\'
%s
\'
'
%
(
formatted_name
,
path
))
i
-=
1
return
success
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录