zoukankan      html  css  js  c++  java
  • 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 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;
  • 相关阅读:
    DNS
    NTP服务
    DHCP服务
    NFS服务、SSHD服务
    samba 、 FTP 、 lrzsz工具
    centos7系统忘记root密码
    linux系统rpm和yum软件包管理
    linux系统命令(调试命令)(nmtui,ip a、ss、ps、uptime、top、lsof、grep,iotop、iftop)
    浅聊TCP的三次握手和四次挥手
    C语言学习笔记--动态库和静态库的使用
  • 原文地址:https://www.cnblogs.com/ceci/p/9271708.html
Copyright © 2011-2022 走看看