npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gm-mobile/locales

v3.12.14-beta.0

Published

## 简介 国际化工具包 - 提供多语言支持和国际化工具函数,被其他组件库内部使用。

Readme

@gm-mobile/locales

简介

国际化工具包 - 提供多语言支持和国际化工具函数,被其他组件库内部使用。

安装

npm install @gm-mobile/locales

使用

快速开始

import { getLocale, setLocale } from '@gm-mobile/locales'

// 设置当前语言
setLocale('en')

// 获取翻译文本
const text = getLocale('确定') // 返回 "OK"

API

导出列表

| 导出项 | 类型 | 说明 | |--------|------|------| | getLocale | 函数 | 根据当前语言获取翻译文本 | | setLocale | 函数 | 设置当前语言 |

函数

setLocale(lng)

设置当前语言。

| 参数 | 说明 | 类型 | 必填 | |------|------|------|------| | lng | 语言标识 | string | 是 |

getLocale(text)

根据当前语言获取翻译文本,找不到翻译时返回原文。

| 参数 | 说明 | 类型 | 必填 | |------|------|------|------| | text | 需要翻译的中文文本 | string | 是 |

返回值string - 翻译后的文本

支持的语言

| 语言标识 | 说明 | |----------|------| | zh | 简体中文(默认) | | zh-HK | 繁体中文(香港) | | en | 英文 | | th | 泰文 | | ug | 维吾尔文 |

示例

切换语言

import { getLocale, setLocale } from '@gm-mobile/locales'

const App = () => {
  return (
    <div>
      <button onClick={() => setLocale('zh')}>中文</button>
      <button onClick={() => setLocale('en')}>English</button>
      <button onClick={() => setLocale('th')}>ไทย</button>

      <p>{getLocale('确定')}</p>
      <p>{getLocale('取消')}</p>
    </div>
  )
}

注意事项

  • 默认语言为简体中文(zh
  • 找不到对应翻译时会返回原文(中文 key)
  • 语言包文件由脚本自动生成,位于 src/lng/ 目录下
  • 其他组件库(如 @gm-mobile/c-react@gm-mobile/react)内部依赖此包进行国际化

相关包