Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@sweetui/sweet-mobile
Advanced tools
Code
import { sweetI18n } from '@sweetui/sweet-mobile';
// 国际化
Vue.use(sweetI18n)
const SweetApp = new Vue({
...
// 注入i18n
i18n: sweetI18n.i18n,
});
app.config.js
文件 可配置language 设置初始语言。本地缓存SWEETLANG字段 > appConfig.language值 > navigator.language
setI18nLanguage
方法,用于切换lang语言包的方法,已注册到全局。/**
* 设置语言包
* @param {String} lang 语言文件名称 en-US
*/
function $i18nLanguage(lang) {
....
}
this.$i18nLanguage(lang)
lang必须与@/lang/*目录下的文件名相同
语言包路径 @/lang/* 即 src/lang/* 例: lang=zh 对应 zh.js
基础定义
export default {
message: {
test: 'hello'
}
}
调用
{{$t("message.test")}} or <p v-html="$t('message.hello')"></p>
在某些情况下,您可能希望将翻译呈现为HTML邮件而不是静态字符串。
export default {
message: {
hello: 'hello <br> world'
}
}
模板如下:
<p v-html="$t('message.hello')"></p>
输出下面的内容(而不是预先格式化的信息)
<p>hello
<!--<br> exists but is rendered as html and not a string-->
world</p>
语言环境消息如下:
export default {
message: {
hello: '{msg} world'
}
}
模板如下:
<p>{{ $t('message.hello', { msg: 'hello' }) }}</p>
输出如下:
<p>hello world</p>
语言环境消息如下:
export default {
message: {
hello: '{0} world'
}
}
模板如下:
<p>{{ $t('message.hello', ['hello']) }}</p>
输出如下:
<p>hello world</p>
列表格式也接受类似数组的对象:
<p>{{ $t('message.hello', {'0': 'hello'}) }}</p>
输出如下:
<p>hello world</p>
语言环境消息如下:
export default {
message: {
hello: '%{msg} world'
}
}
模板如下:
<p>{{ $t('message.hello', { msg: 'hello' }) }}</p>
输出如下:
<p>hello world</p>
你可以翻译成复数形式。您必须定义具有管道|分隔符的区域设置,并在管道分隔符中定义复数形式。
语言环境消息如下:
export default {
car: 'car | cars',
apple: 'no apples | one apple | {count} apples'
}
模板如下:
<p>{{ $tc('car', 1) }}</p>
<p>{{ $tc('car', 2) }}</p>
<p>{{ $tc('apple', 0) }}</p>
<p>{{ $tc('apple', 1) }}</p>
<p>{{ $tc('apple', 10, { count: 10 }) }}</p>
输出如下:
<p>car</p>
<p>cars</p>
<p>no apples</p>
<p>one apple</p>
<p>10 apples</p>
FAQs
Sweet Mobile Core
The npm package @sweetui/sweet-mobile receives a total of 0 weekly downloads. As such, @sweetui/sweet-mobile popularity was classified as not popular.
We found that @sweetui/sweet-mobile demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.