For the complete documentation index, see llms.txt. This page is also available as Markdown.

语言

getLocale 该函数 获取当前用户的 locale 信息,并以此为基础 可用于将应用处理为多语言的 API

如果让用户能以熟悉的语言使用应用,整体 使用体验和可访问性都能显著提升。可用于字符串翻译、日期·时间格式、数字表示等所有需要本地化的场景。

请参考

  • 如果无法获取 locale 信息,则默认 'ko-KR'返回该值。

  • 此 API 和示例 仅可在 Toss 应用环境中 查看。

获取用户语言

SDK 函数: getLocale

签名

function getLocale(): string;

返回值

  • string

    返回用户的 locale 信息。

获取当前用户的 locale 信息

import { getLocale } from '@apps-in-toss/framework';
import { Text } from 'react-native';

function MyPage() {
  const locale = getLocale();

  return <Text>用户的 locale 信息: {locale}</Text>;
}

体验示例应用

apps-in-toss-examples 在仓库中 with-locale 下载代码,或扫描下方二维码亲自体验。

二维码链接: intoss://with-locale

最后更新于

这有帮助吗?