码迷,mamicode.com
首页 > 编程语言 > 详细

ABP实战--修改语言配置XML至Json

时间:2018-07-04 15:59:01      阅读:809      评论:0      收藏:0      [点我收藏+]

标签:try   use   icon   back   tail   leave   selection   ida   level   

ABP实战--修改语言配置XML至Json

标签(空格分隔): 未分类


从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实战--修改语言配置XML至Json

标签:try   use   icon   back   tail   leave   selection   ida   level   

原文地址:https://www.cnblogs.com/ceci/p/9263481.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!