You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where Lang is an attribute of BComponentbase, through which the text of the corresponding language can be output
The international file format is as follows:
{
"Message": "Hello, world",
"Snowman": {
"Data": {
"Title": "snowman"
}
"Body": "great! It's snowing! It's time to make a snowman. James ran out. He made a lot of snow. He put a big snowball on the top to act as the head. He added a scarf and a hat to the snowman and an orange as his nose. He added coal as eyes and buttons. In the evening, James opened the door. What did he see? Snowman moving! James invited it in. The snowman has never been in the room. He said hello to the cat. The cat is playing with paper towels. Soon after, the snowman took James by the hand and went out. They're going up, up in the air! They are flying! What a wonderful night! The next morning, James jumped out of bed. He ran to the door. He wants to thank the snowman, but it's gone. "
}
"Setenlang": "switching English",
"Setcnlang": "switching Chinese",
"Key": "text"
}
At present, there are two built-in languages, English and Chinese, which can be expanded by themselves. For example, the following is the file format of traditional Chinese, with the file name of zh-tw.json:
{
"reg":"註冊",
"login":"登錄"
}
For this file to take effect, just get the Blang instance and set the langlocale property to zh-TW to switch the language.
If you don't want to inherit BComponentbase and want to switch languages, you only need to obtain the Blang instance by dependency injection, and then set the langlocale property to zh-TW to switch languages.
The text was updated successfully, but these errors were encountered:
中文介绍:
WebAssembly 渲染版,进行如下配置:
在 Program 类中增加如下代码即可使用,默认为简体中文
builder.Services.AddSingleton<BLang>();//此处必须单例
Server 渲染版,进行如下设置:
在 Startup 类中增加如下代码即可使用,默认为简体中文
services.AddSingleton<BLang>();//此处必须单例
使用方法
新建组件,继承 BComponentBase 类,可像如下切换语言
可像如下显示当前语言对应的文本
其中,Lang是BComponentBase的一个属性,通过它可输出对应语言的文本
国际化文件格式如下:
目前内置 English 与 中文 两种语言,可以自行扩充语言,例如下面是繁体中文的文件格式,文件名为zh-TW.json:
要让这个文件生效,只需要获取到BLang实例,然后将 LangLocale 属性设置为 zh-TW,即可切换语言。
如果您不想继承 BComponentBase 这个类,又想切换语言,只需要依赖注入获取到BLang实例,然后将 LangLocale 属性设置为 zh-TW,即可切换语言。
English introduction:
The webassembly rendering version is configured as follows:
Add the following code to the program class, which is simplified Chinese by default
Builder. Services. Addsingleton <Blang> (); // a single instance is required here
Server rendering version, set as follows:
Add the following code to the startup class, which is simplified Chinese by default
Services. Addsingleton <Blang> (); // a single instance is required here
How to use
Create a new component, inherit bccomponentbase class, and switch languages as follows
The text corresponding to the current language can be displayed as follows
Where Lang is an attribute of BComponentbase, through which the text of the corresponding language can be output
The international file format is as follows:
At present, there are two built-in languages, English and Chinese, which can be expanded by themselves. For example, the following is the file format of traditional Chinese, with the file name of zh-tw.json:
For this file to take effect, just get the Blang instance and set the langlocale property to zh-TW to switch the language.
If you don't want to inherit BComponentbase and want to switch languages, you only need to obtain the Blang instance by dependency injection, and then set the langlocale property to zh-TW to switch languages.
The text was updated successfully, but these errors were encountered: