从ABP官网下载的Zero的多语言配置默认是使用XML文件的,实际使用中XML是没有Json简洁明了的,所以我们将其修改为Json格式。

  • 修改MyLocalizationConfigurer.cs文件

我们在Core-Localization下找到LocalizationConfigurer.cs文件,将其替换为:

public static void Configure(ILocalizationConfiguration localizationConfiguration)
{
//获得dll的全路径
var location = Assembly.GetEntryAssembly().Location;
var sourceDir = Directory.GetParent(location) + "/Localization/SourceFiles"; localizationConfiguration.Sources.Add(
new DictionaryBasedLocalizationSource(CeciConsts.LocalizationSourceName,
new JsonFileLocalizationDictionaryProvider(sourceDir)
)
);
}

注意,这里获得我们运行目录下的/Localization/SourceFiles下的文件作为资源文件。

  • 修改资源文件的拷贝

同样的SourceFiles下,参照xml文件名添加对应的json文件,并F4设置其`复制到输出目录`为`始终复制`。
添加的Json文件内容参照如下,`culture`标明具体的语言,详细参照ABP文档。

{
"culture": "en",
"texts": {
"HomePage": "Home page",
"About": "About",
"WellcomeMessage": "Welcome to Ceci!",
"FormIsNotValidMessage": "Form is not valid. Please check and fix errors.",
"TenantNameCanNotBeEmpty": "Tenant name can not be empty",
"InvalidUserNameOrPassword": "Invalid user name or password",
"ThereIsNoTenantDefinedWithName{0}": "There is no tenant defined with name {0}",
"TenantIsNotActive": "Tenant {0} is not active.",
"UserIsNotActiveAndCanNotLogin": "User {0} is not active and can not log in.",
"UserEmailIsNotConfirmedAndCanNotLogin": "Your email address is not confirmed. You can not login.",
"UserLockedOutMessage": "The user account has been locked out. Please try again later.",
"PleaseEnterLoginInformation": "Please enter login information",
"TenancyName": "Tenancy name",
"UserNameOrEmail": "User name or email",
"Password": "Password",
"RememberMe": "Remember me",
"LogIn": "Log in",
"LoginFailed": "Login failed!",
"NameSurname": "Name surname",
"UserName": "User name",
"Name": "Name",
"Surname": "Surname",
"EmailAddress": "Email address",
"Tenants": "Tenants",
"SavedSuccessfully": "Saved successfully",
"CreateNewTenant": "Create new tenant",
"AdminEmailAddress": "Admin email address",
"Save": "Save",
"Cancel": "Cancel",
"TenantName_Regex_Description": "Tenant name must be at least 2 chars, starts with a letter and continue with letter, number, dash or underscore.",
"DefaultPasswordIs": "Default password is {0}",
"CanBeEmptyToLoginAsHost": "Can be empty to login as host.",
"Register": "Register",
"OrLoginWith": "Or login with",
"WaitingForActivationMessage": "Your account is waiting to be activated by system admin.",
"TenantSelection": "Tenant Selection",
"TenantSelection_Detail": "Please select one of the following tenants.",
"Logout": "Logout",
"RegisterFormUserNameInvalidMessage": "Please don't enter an email address for username.",
"DatabaseConnectionString": "Database connection string",
"Users": "Users",
"IsActive": "Is active",
"FullName": "Full name",
"CreateNewUser": "Create new user",
"Yes": "Yes",
"No": "No",
"Optional": "Optional",
"LeaveEmptyToSwitchToHost": "Leave empty to switch to the host",
"CurrentTenant": "Current tenant",
"NotSelected": "Not selected",
"Change": "Change",
"ChangeTenant": "Change tenant",
"MultiLevelMenu": "Multi Level Menu",
"Back": "Back",
"SuccessfullyRegistered": "Successfully registered",
"WaitingForEmailActivation": "Your email address should be activated",
"Roles": "Roles",
"DisplayName": "Display Name",
"Edit": "Edit",
"Delete": "Delete",
"CreateNewRole": "Create new role",
"RoleName": "Role Name",
"Actions": "Actions",
"CouldNotCompleteLoginOperation": "Could not complete login operation. Please try again later.",
"CouldNotValidateExternalUser": "Could not validate external user",
"EditRole": "Edit role",
"EditTenant": "Edit tenant",
"EditUser": "Edit user",
"TenantIdIsNotActive{0}": "TenantId {0} is not active",
"UnknownTenantId{0}": "Unknown tenantId {0}",
"ThisFieldIsRequired": "This field is required",
"PleaseWait": "Please wait...",
"Administration": "Administration",
"ClearAll": "Clear all",
"ClearOthers": "Clear others",
"LabelOptions": "Label options",
"Permissions": "Permissions",
"RoleDescription": "Role description",
"Refresh": "Refresh",
"Create": "Create",
"UserDetails": "User details",
"UserRoles": "User roles",
"ConfirmPassword": "Confirm password",
"Version": "Version",
"On": "On",
"Off": "Off",
"AreYouSureWantToDelete": "Are you sure want to delete {0}?",
"StartTyping": "Start Typing",
"Skins": "Skins",
"Settings": "Settings"
}
}
  • 修改简体中文

  ABP Zero中中文简体的标识是zh-Hans,我们需要修改掉,否则Jquery的多语言文件等是无法匹配的。

  1. 修改Seed中的DefaultLanguagesCreator类中的标识,zh-Hans改为zh。
  2. 修改数据库language表中的标识。
  3. 在Core的Localization/SourceFiles中新增Ceci-zh.json。并设置其始终复制。
  • 移除找不到Key时加的[]

  在Core中已经不再建议使用Key的方式来使用默认语言,而是直接将需表达的默认语言表现为Key,但是我们移除掉默认语言的Json后,ABP会在显示语言处加【】标识,我们可以移除这个标识:

Configuration.Localization.WrapGivenTextIfNotFound = false;

ABP实战--修改语言配置XML至Json的更多相关文章

  1. SQL Server 2005的XML数据修改语言(XML DML)

    转:http://www.microsoft.com/china/msdn/library/data/sqlserver/XMLDML.mspx?mfr=true 作为对XQuery语言的扩展,XML ...

  2. ABP进阶教程5 - 多语言配置

    点这里进入ABP进阶教程目录 更新脚本 打开展示层(即JD.CRS.Web.Mvc)的\wwwroot\view-resources\Views\Course\Index.js //用以存放Cours ...

  3. .net 温故知新:【8】.NET 中的配置从xml转向json

    一.配置概述 在.net framework平台中我们常见的也是最熟悉的就是.config文件作为配置,控制台桌面程序是App.config,Web就是web.config,里面的配置格式为xml格式 ...

  4. c#通用配置文件读写类(xml,ini,json)

    .NET下编写程序的时候经常会使用到配置文件.配置文件格式通常有xml.ini.json等几种,操作不同类型配置文件需要使用不同的方法,操作较为麻烦.特别是针对同时应用不同格式配置文件的时候,很容易引 ...

  5. abp 设置默认语言为中文

    abp 设置默认语言为中文 abp的默认语言设置,存放于数据库表AbpSettings中,这样配置可使默认语言为中文: name: Abp.Localization.DefaultLanguageNa ...

  6. c#通用配置文件读写类与格式转换(xml,ini,json)

    .NET下编写程序的时候经常会使用到配置文件.配置文件格式通常有xml.ini.json等几种,操作不同类型配置文件需要使用不同的方法,操作较为麻烦.特别是针对同时应用不同格式配置文件的时候,很容易引 ...

  7. iOS:网络编程中三个数据解析协议HTTP、XML、JSON的详细介绍

    网络编程:HTTP协议.XML数据协议.JSON数据协议: HTTP: 1.HTTP传输数据有四种方式:Get方式.Post方式.同步请求方式.异步请求方式. 说明:同步和异步请求方式在创建链接对象和 ...

  8. XML和JSON

    XML XML(EXtensible Markup Language),可扩展标记语言 特点 XML与操作系统.编程语言的开发平台无关 实现不同系统之间的数据交换 作用: 数据交互 配置应用程序和网站 ...

  9. abp实战-ContosoUniversity Abp版-2添加菜单与创建实体

    这里略过理论篇,但需要了解abp分层,对于小项目来说abp分层有点复杂,这里只是演示,个别地方没有完全按照ddd理论去写,后期我将会完善. 1. 创建ContosoUniversity相关功能的菜单 ...

随机推荐

  1. Intellij IDEA 14的注册机(Java版)

    import java.math.BigInteger; import java.util.Date; import java.util.Random; import java.util.zip.CR ...

  2. .net mvc使用FlexPaper插件实现在线预览PDF,EXCEL,WORD的方法

    FlexPaper插件可以实现在浏览器中在线预览pdf,word,excel等. 在网上看到很多关于这个插件实现预览的技术,但是很难做到word和excel在线预览. pdf很好实现. 首先下载相关的 ...

  3. C# Task

    Task是一种基于任务的编程模型.它与thread的主要区别是,它更加方便对线程进程调度和获取线程的执行结果. Task类和thread类,前者接收的是Action委托类型,后者接收的是Func委托类 ...

  4. max渲染通道元素的范例

    renderElementManager = MaxOps.GetCurRenderElementMgr() renderElementManager.Removeallrenderelements( ...

  5. Day 13 迭代器,生成器.

    一.迭代器 可以进行for循环的 数据类型 str ,list tuple dict set 文件句柄 什么是可迭代对象? 方法一:dir(被测对象) 如果他含有__iter__,那这个对象就叫做可迭 ...

  6. Statement与PreparedStatement区别

    1.性能区别 Statement statement = conn.createStatement(); PreparedStatement preStatement = conn.prepareSt ...

  7. 935. Knight Dialer

    A chess knight can move as indicated in the chess diagram below:  .            This time, we place o ...

  8. BZOJ 5334--[Tjoi2018]数学计算(线段树)

    5334: [Tjoi2018]数学计算 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 220  Solved: 147[Submit][Status ...

  9. String-680. Valid Palindrome II

    Given a non-empty string s, you may delete at most one character. Judge whether you can make it a pa ...

  10. Jmeter Cannot load JDBC driver class 'com.mysql.jdbc.Driver'问题解决方案

    1.下载 mysql-connector-java-5.1.44-bin.jar,哪个版本都可以,按自己的mysql版本来 2.将jar包放到jmeter安装路径下的 apache-jmeter-3. ...