more language stuff

This commit is contained in:
SpikeHD
2022-05-16 20:20:33 -07:00
parent 51dfef5616
commit 4398b4d7ef
3 changed files with 16 additions and 6 deletions

View File

@@ -14,7 +14,7 @@
"grasscutter_jar": "Set Grasscutter Jar", "grasscutter_jar": "Set Grasscutter Jar",
"java_path": "Set Custom Java Path", "java_path": "Set Custom Java Path",
"grasscutter_with_game": "Automatically launch Grasscutter with game", "grasscutter_with_game": "Automatically launch Grasscutter with game",
"language": "Select Language" "language": "Select Language (requires restart)"
}, },
"downloads": { "downloads": {
"grasscutter_stable_data": "Download Grasscutter Stable Data", "grasscutter_stable_data": "Download Grasscutter Stable Data",

View File

@@ -17,7 +17,8 @@ interface IState {
grasscutter_path: string grasscutter_path: string
java_path: string java_path: string
grasscutter_with_game: boolean grasscutter_with_game: boolean
language_options: { [key: string]: string }[] language_options: { [key: string]: string }[],
current_language: string
} }
export default class Options extends React.Component<IProps, IState> { export default class Options extends React.Component<IProps, IState> {
@@ -29,7 +30,8 @@ export default class Options extends React.Component<IProps, IState> {
grasscutter_path: '', grasscutter_path: '',
java_path: '', java_path: '',
grasscutter_with_game: false, grasscutter_with_game: false,
language_options: [] language_options: [],
current_language: 'en'
} }
} }
@@ -42,7 +44,8 @@ export default class Options extends React.Component<IProps, IState> {
grasscutter_path: config.grasscutter_path || '', grasscutter_path: config.grasscutter_path || '',
java_path: config.java_path || '', java_path: config.java_path || '',
grasscutter_with_game: config.grasscutter_with_game || false, grasscutter_with_game: config.grasscutter_with_game || false,
language_options: languages language_options: languages,
current_language: config.language || 'en'
}) })
this.forceUpdate() this.forceUpdate()
@@ -115,11 +118,16 @@ export default class Options extends React.Component<IProps, IState> {
<Tr text="options.language" /> <Tr text="options.language" />
</div> </div>
<div className='OptionValue'> <div className='OptionValue'>
<select onChange={(event) => { <select defaultValue={this.state.current_language} onChange={(event) => {
this.setLanguage(event.target.value) this.setLanguage(event.target.value)
}}> }}>
{this.state.language_options.map(lang => ( {this.state.language_options.map(lang => (
<option key={Object.keys(lang)[0]} value={Object.keys(lang)[0]}>{lang[Object.keys(lang)[0]]}</option> <option
key={Object.keys(lang)[0]}
value={Object.keys(lang)[0]}>
{lang[Object.keys(lang)[0]]}
</option>
))} ))}
</select> </select>
</div> </div>

View File

@@ -18,6 +18,7 @@ let defaultConfig: Configuration
startup_launch: false, startup_launch: false,
last_ip: '', last_ip: '',
last_port: '', last_port: '',
language: 'en',
} }
})() })()
@@ -34,6 +35,7 @@ export interface Configuration {
startup_launch: boolean startup_launch: boolean
last_ip: string last_ip: string
last_port: string last_port: string
language: string
} }
export async function setConfigOption(key: string, value: any): Promise<void> { export async function setConfigOption(key: string, value: any): Promise<void> {