react.dev
react.dev copied to clipboard
[conditional-rendering] Make object data easier for translation
While translating conditional-rendering page I encountered one small issue. Namely, last (3rd) challenge solution has list of objects in the code which are referenced by its names. Name of the object is not the property of the object, so I needed to make workaround. Since I'm trying to translate all the text, including object property values, I needed to introduce name field to the object, similar to the example at the end of thinking-in-react page:
const PRODUCTS = [
{category: "Fruits", price: "$1", stocked: true, name: "Apple"},
{category: "Fruits", price: "$1", stocked: true, name: "Dragonfruit"},
{category: "Fruits", price: "$2", stocked: false, name: "Passionfruit"},
{category: "Vegetables", price: "$2", stocked: true, name: "Spinach"},
{category: "Vegetables", price: "$4", stocked: false, name: "Pumpkin"},
{category: "Vegetables", price: "$1", stocked: true, name: "Peas"}
];
I saw that some other languages also have similar workaround:
French:
I didn't want to use either english names as in the french solution nor non-english names of variables as in the spanish solution. My idea was to have all functions/variables/etc. in english and all object values on my mother tongue, Serbian. I've made this PR based on the changes in Serbian repository: https://github.com/reactjs/sr.react.dev/pull/99