Hi how would you handle internationalization with this for this for example Ice Cream in german is Eis and in french its Glace i don't know if making the switch logic on hardcoded values a good idea
btw
this
<buttononClick={(e)=>this.handleClick(e)}>{this.props.text}// this.props.text = "Pizza", "Cheeseburger" or "Ice Cream"</button>
works the same as this:
<buttononClick={this.handleClick}>{this.props.text}// this.props.text = "Pizza", "Cheeseburger" or "Ice Cream"</button>
There are a surprising number of uncapitalized language names, among other grammatical errors, in this callout of the lack of i18n considerations. Also, while "ice" in French is indeed "glace" (not capitalized btw), "ice cream" is actually "crème glacée", and "Eis" (which, you're right, German writers would capitalize) refers just to "ice", not "ice cream".
I know that "glace" in French is not capitalized, I wanted to go with the same format from the buttons.
I wanted to point out that the implementation is pretty fragile if the business decides one day that more languages need to be supported
something like the following would be safe ass the text will most likely be used as a i18n key depending on the library that is used
handleClick(itemName){if(this.props[`order${itemName}`]===undefined){return()=>{console.log("I'm sorry. We don't have that menu item.")};}returnthis.props[`order${itemName}`];}<buttononClick={this.handleClick(this.props.text)}>{this.props.text}// this.props.text = "Pizza", "Cheeseburger" or "Ice Cream"</button>
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi how would you handle internationalization with this for this for example Ice Cream in german is Eis and in french its Glace i don't know if making the switch logic on hardcoded values a good idea
btw
this
works the same as this:
There are a surprising number of uncapitalized language names, among other grammatical errors, in this callout of the lack of i18n considerations. Also, while "ice" in French is indeed "glace" (not capitalized btw), "ice cream" is actually "crème glacée", and "Eis" (which, you're right, German writers would capitalize) refers just to "ice", not "ice cream".
I know that "glace" in French is not capitalized, I wanted to go with the same format from the buttons.
I wanted to point out that the implementation is pretty fragile if the business decides one day that more languages need to be supported
something like the following would be safe ass the text will most likely be used as a i18n key depending on the library that is used