| |

VerySource

 Forgot password?
 Register
Search
View: 883|Reply: 9

Chinese-English conversion under Struts

[Copy link]

2

Threads

12

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-5 06:00:01
| Show all posts |Read mode
Internationalization of applications in the Struts framework (Chinese-English translation)
I have 3 Resoutce Bundle resource bundles
ApplicationResources_en.properties
The content is as follows label.welcome.year = Happy New Year

ApplicationResources_en.properties
label.welcome.year = Happy New Year

ApplicationResources_temp.properties
label.welcome.year = Happy New Year


I compiled the temporary Chinese resources (under DOS)
native2ascii -encoding gb2312 ApplicationResources_temp.properties ApplicationResources_zh_CN.properties

But I still run E. I changed the language.
 
Besides, how can I click a button to automatically convert the language between English [en] and Chinese (中国) [zh-cn]
 
I wish everyone a happy New Year
Reply

Use magic Report

2

Threads

12

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-5 10:48:01
| Show all posts
This is the page called

<% @ page contentType = "text / html; charset = GBK"%>
<% @ taglib uri = "/ WEB-INF / struts-bean.tld" prefix = "bean"%>
<html>
<head>
<title> jsp1 </ title>
</ head>
<body bgcolor = "# ffffff">
<h1>
<bean: message key = "label.welcome.year" />
</ h1>
</ body>
</ html>
Reply

Use magic Report

2

Threads

12

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-2-14 16:45:01
| Show all posts
Conversion done
There is one thing I don't understand
Just
How to implement a button click event
How about the conversion between Chinese and English?

 Without manual changes
Tools → Internet Options → Language to change his language

Realize it with events
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-9 14:00:02
| Show all posts
The corresponding button passes the corresponding locale parameter:
Locale l = this.getLocale (request);
l = new Locale (languageForm.getLanguage (), ""); // Get your selected language
request.getSession (). setAttribute (Globals.LOCALE_KEY, l); // Save to Session
Reply

Use magic Report

0

Threads

63

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-5-9 18:45:01
| Show all posts
Don't change IE, use upstairs
Reply

Use magic Report

2

Threads

12

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-5-26 22:45:01
| Show all posts
Can you pass it to the example above?
Brother, thank you in advance
Reply

Use magic Report

0

Threads

63

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-5-28 12:00:01
| Show all posts
simple

<html: form action = "/ changeLanguage.do">
<html: select property = "language">
  <html: option value = "en"> English </ html: option>
  <html: option value = "zh"> Chinese </ html: option>
</ html: select>
<html: submit> Change </ html: submit>
</ html: form>

public class LanguageForm extends ActionForm {
  private String language; // getter&setter
}
Then inside the corresponding Action:
Locale l = new Locale (languageForm.getLanguage ());
setLocale (request, l);
Reply

Use magic Report

2

Threads

12

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-11 20:15:02
| Show all posts
Get it done
Thank you old
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-20 17:45:01
| Show all posts
Do not directly convert in the project, first native2ascii -encoding gb2312 a.text b.text, and then copy the converted code to ApplicationResources_zh_CN.properties
Reply

Use magic Report

2

Threads

12

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-21 10:00:02
| Show all posts
Okay, thank you for the old man
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list