Closed pixelzoom closed 4 years ago
I think I'm going to leave this one open for now. After discussing the interface with Ariel, I may well remove a lot of the stuff from the parameter panel and show this information a different way. The one that probably most needs this is where I put up "In phase! Path Difference = xx λ". That is also somewhat likely to change (for the same reason). I'll come back to this after I have thought more on those issues. It's good to have the format for JSON though. Thanks.
That sounds like an excellent plan.
Some of these were eliminated from the code. All those remaining (and some new ones) are now being handled this way.
Related to #1 (code review).
In general, don't use concatenation to form strings that will appear in the user interface.
Here are some example, in XrayParameterPanel.js:
Which looks like this in the sim:
The reason you shouldn't use string concatenation has to do with translation to other languages. For example, consider the string "Incident Angle = 60.0°". English is a language that reads left-to-right, so this makes sense. But other languages read right-to-left, and we want to support that.
The general way to address this is to use what's called a "string pattern". A string pattern contains named placeholders that can be filled in with values. The placeholders are surround with double curly brackets, like
{{value}}
. The string pattern for incident angle would look like this in xray-diffraction-strings_en.json:This allows the translator to change the order of terms in the expression.
Here's how that string pattern would be used in XrayParameterPanel.js:
If you want to address this issue, you should examine all of your
Text
andRichText
instances to see how you're creating the strings that they use. For mathematical expressions like "2d sin(theta)= 13.5Å", you could probably get away with using string concatenation. But when in doubt, it's best to make the order translatable.