phetsims / fluid-pressure-and-flow

"Fluid Pressure and Flow" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
8 stars 5 forks source link

How should we name string keys for units? #301

Open zepumph opened 7 years ago

zepumph commented 7 years ago

In the strings file there is

{  "fluxUnitsMetric": {
    "value": "L / (m<sup>2</sup>s)"
  },
  "mPerSPerS": {
    "value": "m/s<sup>2</sup>"
  },}

It seems like we should solidify the way that we are labeling units strings. Either name them for what they are being used for, or camel case their literal value, but we should choose one. @pixelzoom is there a pattern that PhET tends to prefer?

pixelzoom commented 7 years ago

@zepumph asked:

@pixelzoom is there a pattern that PhET tends to prefer?

I'm not aware of any standard. In my Java sims and their HTML5 ports, I typically gave all units-related strings a "units" prefix. For example in molarity_en.json:

  "units.liters": {
    "value": "L"
  },
  "units.molarity": {
    "value": "M"
  },
  "units.moles": {
    "value": "mol"
  },

Looks like some other devs have been using the "units" prefix too - see blackbody-spectrum, capacitor-lab-basics, coulombs-law, gravity-force-lab, inverse-square-law-common, neuron.

The idea with prefixes ("units", "pattern",...) was to provide context, since the Java/Flash Translation Utility was basic. The plan for Rosetta is to provide more context via metadata, but it's unclear when (or if) that will get off the ground.

In unit-rates, I did not use a "units" prefix. I inherited that sim from another developer, and I decided that I don't feel too strongly about the "units" prefix.