i18n internationalization

2023-12-03 11:28
文章标签 i18n internationalization

本文主要是介绍i18n internationalization,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

package i18n;import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;/*** 国际化internationalization* i18n** @author ZengWenFeng* @date 2015.11.23*/
public class I18nDemo
{public static void main(String[] args){Locale locale = new Locale("zh", "CN");
//		Locale locale = new Locale("en", "US");Locale l01 = Locale.US;Locale l02 = Locale.getDefault();System.out.println("C  = " + l01.getCountry());System.out.println("L = " + l01.getLanguage());System.out.println("C  = " + l02.getCountry());System.out.println("L = " + l02.getLanguage());////   E:\PRJ_J2EE\PrjFlexJava\java_src\info_en_US.propertiesResourceBundle resource = ResourceBundle.getBundle("info", locale);
//		ResourceBundle resource = ResourceBundle.getBundle("info", Locale.CHINESE);
//		ResourceBundle resource = ResourceBundle.getBundle("info", Locale.SIMPLIFIED_CHINESE);// info_en_US.propertiesString username = resource.getString("username");String password = resource.getString("passwd");String infoSuccess = resource.getString("info.success");String infoError = resource.getString("info.error");String v_userName = "admin";String v_password = "123";if (v_userName.equals(username) && v_password.equals(password)){String success = MessageFormat.format(infoSuccess, username);System.out.println(success);}else{System.out.println(infoError);}}
}

这篇关于i18n internationalization的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/449270

相关文章

vue3使用vue-i18n(最全攻略踩坑记)

1.安装vue-i18n "vue-i18n": "^9.2.2", 2.新建locales目录 3.新建index.js // 导入你的本地化消息文件import { createI18n } from "vue-i18n";import enMessages from "./en.json";import zhCNMessages from "./zh-CN.json";im

Yii2多语言设置 yii2-国际化-i18n组件的完全配置和使用

配置i18n到web.php 在config/web.php中的config数组加入以下内容。其中,language为全局语言设置;basePath的@app/common/messages等同于,项目目录下common/messages文件夹(这个文件夹需要自行创建,当然大家可以设置自定义目录,代表映射目录);sourceLanguage,即需要被转化的语言,这里选择英语为源语言;fil

vue3使用i18n实现国际化

安装vue-i18n npm install vue-i18n 创建一个ts文件用于存储各种翻译 globalLang.ts的内容如下: export default {"cn": {},"en": {},"de": {},"es": {},"fr": {},"id": {},"it": {},"jp": {},"kr": {},"pt": {},"tw": {}}; 在main.

rails 中i18n实现本地化

在rails中写东西时,因为默认语言是英文的,所以很多已有的提示都是英语,而这对于一个中文网站来说并不友好. 所以一般会使用i18n来实现本地化 在application.rb文件中 写入 config.i18n.default_locale = 'zh_CN' 然后在config/locales文件下 创建 zh_CN.yml文件  内容格式如下: zh

使用vscode插件du-i18n处理前端项目国际化翻译多语言

前段时间我写了一篇关于项目国际化使用I18n组件的文章,Vue3 + TS 使用国际化组件I18n,那个时候还没真正在项目中使用,需求排期还没有定,相当于是预研。 当时就看了一下大概怎么用,改了一个简单的页面,最近需求下来了,开始整个项目去做了,才发现工作量有点大,好像也有点傻,一个个地取变量名,翻译,替换。。。换了几个页面之后,发现眼睛都要花了,又累又困,还容易出错,于是跟同事吐槽了一下,没想

Vue I18n国际化插件

Vue I18n国际化插件 安装目录结构及文件内容./locales/lang/zh.js./locales/lang/en.js./locales/index.js main.js引入页面具体使用及语言切换(Vue3)刷新保存原语言,App.vue添加路由守卫注意点 中文文档: https://kazupon.github.io/vue-i18n/zh/introduction.

Spring 读取i18n国际化资源文件的工具类

现有一个国际化资源文件demoUser_zh_CN.properties如下: demoUser.create.success=创建成功demoUser.update.success=更新成功demoUser.delete.success=删除成功demoUser.start.success=送审成功demoUser.approval.success=审核成功demoUser.cl

i18n-demo

一、demo 1、资源文件准备 resources下放各个语言文件,直接放resources下都行。我新建一个文件夹,

react-native-i18n 语言切换工具

yarn add react-native-i18n Android 在./android/settings.gradle文件中添加下列代码: include ':app', ':react-native-i18n'project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_mod

struts2的国际化i18n

本文主要介绍struts2的国际化,首先在struts.xml文件中配置 常量值 <constant name="struts.custom.i18n.resources" value="app"/>(app为properties部分文件名,全名为app_en_US.properties或app_zh_CN.properties) app_en_US.propertie内容 city=