Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Global I18n Standard
提交
c009fd56
G
Global I18n Standard
项目概览
OpenHarmony
/
Global I18n Standard
大约 1 年 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Global I18n Standard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c009fd56
编写于
3月 14, 2022
作者:
S
sunyaozu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix part dependency
Signed-off-by:
N
sunyaozu
<
sunyaozu@huawei.com
>
上级
d04f3e18
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
3 addition
and
52 deletion
+3
-52
frameworks/intl/BUILD.gn
frameworks/intl/BUILD.gn
+1
-9
frameworks/intl/src/preferred_language.cpp
frameworks/intl/src/preferred_language.cpp
+0
-40
i18n.gni
i18n.gni
+2
-2
interfaces/native/innerkits/preferred_language/include/preferred_language.h
...innerkits/preferred_language/include/preferred_language.h
+0
-1
未找到文件。
frameworks/intl/BUILD.gn
浏览文件 @
c009fd56
...
...
@@ -26,10 +26,7 @@ config("preferred_language_config") {
}
ohos_shared_library("preferred_language") {
public_configs = [ ":preferred_language_config" ]
include_dirs = [
"//base/global/resmgr_standard/frameworks/resmgr/include",
"include",
]
include_dirs = [ "include" ]
sources = [ "src/preferred_language.cpp" ]
cflags_cc = [
"-Wall",
...
...
@@ -37,12 +34,7 @@ ohos_shared_library("preferred_language") {
]
deps = [ "//base/global/i18n_standard/frameworks/intl:intl_util" ]
external_deps = [
"ability_base:want",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"resmgr_standard:global_resmgr",
"startup_l2:syspara",
]
subsystem_name = "global"
...
...
frameworks/intl/src/preferred_language.cpp
浏览文件 @
c009fd56
...
...
@@ -12,11 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <regex>
#include "bundle_mgr_client.h"
#include "hap_resource.h"
#include "hilog/log.h"
#include "ipc_skeleton.h"
#include "locale_config.h"
#include "locale_info.h"
#include "parameter.h"
...
...
@@ -29,7 +24,6 @@ const char *PreferredLanguage::RESOURCE_PATH_HEAD = "/data/accounts/account_0/ap
const
char
*
PreferredLanguage
::
RESOURCE_PATH_TAILOR
=
"/assets/entry/resources.index"
;
const
char
*
PreferredLanguage
::
RESOURCE_PATH_SPLITOR
=
"/"
;
const
char
*
PreferredLanguage
::
PREFERRED_LANGUAGES
=
"persist.sys.preferredLanguages"
;
static
constexpr
OHOS
::
HiviewDFX
::
HiLogLabel
LABEL
=
{
LOG_CORE
,
0xD001E00
,
"LocaleConfig"
};
bool
PreferredLanguage
::
AddPreferredLanguageExist
(
std
::
vector
<
std
::
string
>
&
preferredLanguageList
,
int
languageIdx
,
int
index
,
const
std
::
string
&
language
)
...
...
@@ -180,40 +174,6 @@ std::vector<std::string> PreferredLanguage::GetPreferredLanguageList()
return
list
;
}
std
::
set
<
std
::
string
>
PreferredLanguage
::
GetResources
()
{
pid_t
uid
=
OHOS
::
IPCSkeleton
::
GetCallingUid
();
std
::
string
bundleName
=
""
;
OHOS
::
AppExecFwk
::
BundleMgrClient
client
;
bool
status
=
client
.
GetBundleNameForUid
(
uid
,
bundleName
);
if
(
!
status
)
{
HiviewDFX
::
HiLog
::
Error
(
LABEL
,
"Failed to get bundleName"
);
}
const
std
::
string
resourcePath
=
RESOURCE_PATH_HEAD
+
bundleName
+
RESOURCE_PATH_SPLITOR
+
bundleName
+
RESOURCE_PATH_TAILOR
;
const
OHOS
::
Global
::
Resource
::
HapResource
*
resource
=
OHOS
::
Global
::
Resource
::
HapResource
::
LoadFromIndex
(
resourcePath
.
c_str
(),
nullptr
);
const
std
::
vector
<
std
::
string
>
qualifiers
=
resource
->
GetQualifiers
();
std
::
set
<
std
::
string
>
result
;
std
::
regex
languagePattern
(
"type:0.*str:([a-z]{2})"
);
std
::
regex
countryPattern
(
"type:1.*str:([A-Z]{2})"
);
for
(
size_t
i
=
0
;
i
<
qualifiers
.
size
();
i
++
)
{
std
::
smatch
match
;
bool
found
=
regex_search
(
qualifiers
[
i
],
match
,
languagePattern
);
if
(
!
found
)
{
continue
;
}
std
::
string
locale
=
match
.
str
(
1
);
found
=
regex_search
(
qualifiers
[
i
],
match
,
countryPattern
);
if
(
found
)
{
locale
+=
"-"
;
locale
+=
match
.
str
(
1
);
}
result
.
insert
(
locale
);
}
return
result
;
}
bool
PreferredLanguage
::
IsMatched
(
const
std
::
string
&
preferred
,
const
std
::
string
&
resource
)
{
LocaleInfo
preferredLocaleInfo
(
preferred
);
...
...
i18n.gni
浏览文件 @
c009fd56
...
...
@@ -9,8 +9,8 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
declare_args() {
i18n_standard_telephony_core_service_exists =
fals
e
i18n_standard_telephony_core_service_exists =
tru
e
}
interfaces/native/innerkits/preferred_language/include/preferred_language.h
浏览文件 @
c009fd56
...
...
@@ -35,7 +35,6 @@ private:
const
std
::
string
&
language
);
static
bool
AddPreferredLanguageExist
(
std
::
vector
<
std
::
string
>
&
preferredLangList
,
int
languageIdx
,
int
index
,
const
std
::
string
&
language
);
static
std
::
set
<
std
::
string
>
GetResources
();
static
bool
IsMatched
(
const
std
::
string
&
preferred
,
const
std
::
string
&
resource
);
static
bool
IsValidLanguage
(
const
std
::
string
&
language
);
static
bool
IsValidTag
(
const
std
::
string
&
tag
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录