@terraware/web-components 4.3.3 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/components/VirtualWalkthrough/AnnotationEditPane.d.ts +1 -21
  2. package/components/VirtualWalkthrough/AnnotationEditPane.d.ts.map +1 -1
  3. package/components/VirtualWalkthrough/AnnotationEditPane.js +18 -17
  4. package/components/VirtualWalkthrough/CameraInfo.d.ts +1 -7
  5. package/components/VirtualWalkthrough/CameraInfo.d.ts.map +1 -1
  6. package/components/VirtualWalkthrough/CameraInfo.js +5 -4
  7. package/components/VirtualWalkthrough/ControlsInfoPane.d.ts +1 -25
  8. package/components/VirtualWalkthrough/ControlsInfoPane.d.ts.map +1 -1
  9. package/components/VirtualWalkthrough/ControlsInfoPane.js +23 -22
  10. package/components/VirtualWalkthrough/SplatControls.d.ts +1 -20
  11. package/components/VirtualWalkthrough/SplatControls.d.ts.map +1 -1
  12. package/components/VirtualWalkthrough/SplatControls.js +11 -13
  13. package/components/VirtualWalkthrough/VirtualWalkthroughViewer.d.ts +1 -3
  14. package/components/VirtualWalkthrough/VirtualWalkthroughViewer.d.ts.map +1 -1
  15. package/components/VirtualWalkthrough/VirtualWalkthroughViewer.js +1 -3
  16. package/index.d.ts +5 -1
  17. package/index.d.ts.map +1 -1
  18. package/index.js +2 -0
  19. package/license-report.html +1 -1
  20. package/package.json +2 -1
  21. package/strings/csv/en.csv +50 -0
  22. package/strings/csv/es.csv +50 -0
  23. package/strings/csv/fr.csv +50 -0
  24. package/strings/csv/instructions-es.txt +14 -0
  25. package/strings/csv/instructions-fr.txt +14 -0
  26. package/strings/csv/instructions.txt +13 -0
  27. package/strings/export.d.ts +36 -0
  28. package/strings/export.d.ts.map +1 -0
  29. package/strings/export.js +116 -0
  30. package/strings/index.d.ts +22 -0
  31. package/strings/index.d.ts.map +1 -0
  32. package/strings/index.js +62 -0
  33. package/strings/locales.d.ts +38 -0
  34. package/strings/locales.d.ts.map +1 -0
  35. package/strings/locales.js +42 -0
  36. package/strings/strings-en.d.ts +52 -0
  37. package/strings/strings-en.d.ts.map +1 -0
  38. package/strings/strings-en.js +54 -0
  39. package/strings/strings-es.d.ts +52 -0
  40. package/strings/strings-es.d.ts.map +1 -0
  41. package/strings/strings-es.js +54 -0
  42. package/strings/strings-fr.d.ts +52 -0
  43. package/strings/strings-fr.d.ts.map +1 -0
  44. package/strings/strings-fr.js +54 -0
  45. package/strings/strings-gx.d.ts +52 -0
  46. package/strings/strings-gx.d.ts.map +1 -0
  47. package/strings/strings-gx.js +54 -0
  48. package/virtualWalkthrough.d.ts +2 -4
  49. package/virtualWalkthrough.d.ts.map +1 -1
package/index.js CHANGED
@@ -52,4 +52,6 @@ export { index as Svg };
52
52
  export { default as Table } from './components/table/index.js';
53
53
  export { CellDateRenderer, default as CellRenderer } from './components/table/TableCellRenderer.js';
54
54
  export { descendingComparator, getComparator, stableSort } from './components/table/sort.js';
55
+ export { getLocale, getStrings, setLocale, useStrings } from './strings/index.js';
56
+ export { findLocaleDetails, getSupportedLocales, supportedLocales } from './strings/locales.js';
55
57
  export { default as theme } from './theme.js';
@@ -48,6 +48,6 @@ td {
48
48
  }
49
49
 
50
50
  </style>
51
- <table><thead><tr><th class="string">department</th><th class="string">related to</th><th class="string">name</th><th class="string">license period</th><th class="string">material / not material</th><th class="string">license type</th><th class="string">link</th><th class="string">remote version</th><th class="string">installed version</th><th class="string">defined version</th><th class="string">author</th></tr></thead><tbody><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@dnd-kit/core</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/clauderic/dnd-kit.git</td><td class="string">6.3.1</td><td class="string">6.3.1</td><td class="string">^6.0.7</td><td class="string">Claudéric Demers</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@dnd-kit/sortable</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/clauderic/dnd-kit.git</td><td class="string">10.0.0</td><td class="string">10.0.0</td><td class="string">^10.0.0</td><td class="string">Claudéric Demers</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@emotion/react</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/emotion-js/emotion.git#main</td><td class="string">11.14.0</td><td class="string">11.14.0</td><td class="string">^11.11.3</td><td class="string">Emotion Contributors</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@emotion/styled</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/emotion-js/emotion.git#main</td><td class="string">11.14.1</td><td class="string">11.14.1</td><td class="string">^11.11.3</td><td class="string">n/a</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@mui/icons-material</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/mui/material-ui.git</td><td class="string">6.5.0</td><td class="string">6.5.0</td><td class="string">^6.0.0</td><td class="string">MUI Team</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@mui/lab</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/mui/material-ui.git</td><td class="string">6.0.1-beta.36</td><td class="string">6.0.1-beta.36</td><td class="string">^6.0.1-beta.36</td><td class="string">MUI Team</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@mui/material</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/mui/material-ui.git</td><td class="string">6.5.0</td><td class="string">6.5.0</td><td class="string">^6.0.0</td><td class="string">MUI Team</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@mui/x-date-pickers</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/mui/mui-x.git</td><td class="string">7.29.4</td><td class="string">7.29.4</td><td class="string">^7.22.0</td><td class="string">MUI Team</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@playcanvas/react</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/playcanvas/react.git</td><td class="string">0.11.5</td><td class="string">0.11.5</td><td class="string">0.11.5</td><td class="string">n/a</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">classnames</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/JedWatson/classnames.git</td><td class="string">2.5.1</td><td class="string">2.5.1</td><td class="string">^2.3.2</td><td class="string">Jed Watson</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">geojson</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">http://github.com/caseycesari/geojson.js.git</td><td class="string">0.5.0</td><td class="string">0.5.0</td><td class="string">^0.5.0</td><td class="string">Casey Cesari</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">luxon</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/moment/luxon.git</td><td class="string">3.7.2</td><td class="string">3.7.2</td><td class="string">^3.3.0</td><td class="string">Isaac Cambron</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">marked</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git://github.com/markedjs/marked.git</td><td class="string">16.4.2</td><td class="string">16.4.2</td><td class="string">^16.2.1</td><td class="string">Christopher Jeffrey</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">material-react-table</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/KevinVandy/material-react-table.git</td><td class="string">3.2.1</td><td class="string">3.2.1</td><td class="string">^3.2.1</td><td class="string">KevinVandy</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">playcanvas</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/playcanvas/engine.git</td><td class="string">2.21.3</td><td class="string">2.21.3</td><td class="string">2.21.3</td><td class="string">PlayCanvas <support@playcanvas.com></td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">prettier</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/prettier/prettier.git</td><td class="string">3.9.6</td><td class="string">3.8.1</td><td class="string">^3.8.1</td><td class="string">James Long</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">react-intersection-observer</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/thebuilder/react-intersection-observer.git</td><td class="string">9.16.0</td><td class="string">9.16.0</td><td class="string">^9.5.2</td><td class="string">Daniel Schmidt</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">react-multi-carousel</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/YIZHUANG/react-multi-carousel.git</td><td class="string">2.8.6</td><td class="string">2.8.6</td><td class="string">^2.8.2</td><td class="string">YI ZHUANG https://github.com/YIZHUANG</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">react-responsive</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git://github.com/contra/react-responsive.git</td><td class="string">9.0.2</td><td class="string">9.0.2</td><td class="string">^9.0.2</td><td class="string">Contra <yo@contra.io> (https://contra.io)</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">sass</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/sass/dart-sass.git</td><td class="string">1.102.0</td><td class="string">1.97.2</td><td class="string">^1.75.0</td><td class="string">Natalie Weizenbaum nweiz@google.com https://github.com/nex3</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">tinycolor2</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/bgrins/TinyColor.git</td><td class="string">1.6.0</td><td class="string">1.6.0</td><td class="string">^1.6.0</td><td class="string">Brian Grinstead <briangrinstead@gmail.com> (http://briangrinstead.com)</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">web-vitals</td><td class="string">perpetual</td><td class="string">material</td><td class="string">Apache-2.0</td><td class="string">git+https://github.com/GoogleChrome/web-vitals.git</td><td class="string">3.5.2</td><td class="string">3.5.2</td><td class="string">^3.5.2</td><td class="string">Philip Walton philip@philipwalton.com http://philipwalton.com</td></tr></tbody></table>
51
+ <table><thead><tr><th class="string">department</th><th class="string">related to</th><th class="string">name</th><th class="string">license period</th><th class="string">material / not material</th><th class="string">license type</th><th class="string">link</th><th class="string">remote version</th><th class="string">installed version</th><th class="string">defined version</th><th class="string">author</th></tr></thead><tbody><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@dnd-kit/core</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/clauderic/dnd-kit.git</td><td class="string">6.3.1</td><td class="string">6.3.1</td><td class="string">^6.0.7</td><td class="string">Claudéric Demers</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@dnd-kit/sortable</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/clauderic/dnd-kit.git</td><td class="string">10.0.0</td><td class="string">10.0.0</td><td class="string">^10.0.0</td><td class="string">Claudéric Demers</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@emotion/react</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/emotion-js/emotion.git#main</td><td class="string">11.14.0</td><td class="string">11.14.0</td><td class="string">^11.11.3</td><td class="string">Emotion Contributors</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@emotion/styled</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/emotion-js/emotion.git#main</td><td class="string">11.14.1</td><td class="string">11.14.1</td><td class="string">^11.11.3</td><td class="string">n/a</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@mui/icons-material</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/mui/material-ui.git</td><td class="string">6.5.0</td><td class="string">6.5.0</td><td class="string">^6.0.0</td><td class="string">MUI Team</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@mui/lab</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/mui/material-ui.git</td><td class="string">6.0.1-beta.36</td><td class="string">6.0.1-beta.36</td><td class="string">^6.0.1-beta.36</td><td class="string">MUI Team</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@mui/material</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/mui/material-ui.git</td><td class="string">6.5.0</td><td class="string">6.5.0</td><td class="string">^6.0.0</td><td class="string">MUI Team</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@mui/x-date-pickers</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/mui/mui-x.git</td><td class="string">7.29.4</td><td class="string">7.29.4</td><td class="string">^7.22.0</td><td class="string">MUI Team</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">@playcanvas/react</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/playcanvas/react.git</td><td class="string">0.11.5</td><td class="string">0.11.5</td><td class="string">0.11.5</td><td class="string">n/a</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">classnames</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/JedWatson/classnames.git</td><td class="string">2.5.1</td><td class="string">2.5.1</td><td class="string">^2.3.2</td><td class="string">Jed Watson</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">csv-parse</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">https://github.com/adaltas/node-csv.git</td><td class="string">5.6.0</td><td class="string">5.6.0</td><td class="string">^5.5.5</td><td class="string">David Worms <david@adaltas.com> (https://www.adaltas.com)</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">geojson</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">http://github.com/caseycesari/geojson.js.git</td><td class="string">0.5.0</td><td class="string">0.5.0</td><td class="string">^0.5.0</td><td class="string">Casey Cesari</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">luxon</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/moment/luxon.git</td><td class="string">3.7.2</td><td class="string">3.7.2</td><td class="string">^3.3.0</td><td class="string">Isaac Cambron</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">marked</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git://github.com/markedjs/marked.git</td><td class="string">16.4.2</td><td class="string">16.4.2</td><td class="string">^16.2.1</td><td class="string">Christopher Jeffrey</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">material-react-table</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/KevinVandy/material-react-table.git</td><td class="string">3.2.1</td><td class="string">3.2.1</td><td class="string">^3.2.1</td><td class="string">KevinVandy</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">playcanvas</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/playcanvas/engine.git</td><td class="string">2.21.3</td><td class="string">2.21.3</td><td class="string">2.21.3</td><td class="string">PlayCanvas <support@playcanvas.com></td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">prettier</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/prettier/prettier.git</td><td class="string">3.9.6</td><td class="string">3.8.1</td><td class="string">^3.8.1</td><td class="string">James Long</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">react-intersection-observer</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/thebuilder/react-intersection-observer.git</td><td class="string">9.16.0</td><td class="string">9.16.0</td><td class="string">^9.5.2</td><td class="string">Daniel Schmidt</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">react-multi-carousel</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/YIZHUANG/react-multi-carousel.git</td><td class="string">2.8.6</td><td class="string">2.8.6</td><td class="string">^2.8.2</td><td class="string">YI ZHUANG https://github.com/YIZHUANG</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">react-responsive</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git://github.com/contra/react-responsive.git</td><td class="string">9.0.2</td><td class="string">9.0.2</td><td class="string">^9.0.2</td><td class="string">Contra <yo@contra.io> (https://contra.io)</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">sass</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/sass/dart-sass.git</td><td class="string">1.102.0</td><td class="string">1.97.2</td><td class="string">^1.75.0</td><td class="string">Natalie Weizenbaum nweiz@google.com https://github.com/nex3</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">tinycolor2</td><td class="string">perpetual</td><td class="string">material</td><td class="string">MIT</td><td class="string">git+https://github.com/bgrins/TinyColor.git</td><td class="string">1.6.0</td><td class="string">1.6.0</td><td class="string">^1.6.0</td><td class="string">Brian Grinstead <briangrinstead@gmail.com> (http://briangrinstead.com)</td></tr><tr><td class="string">terraware</td><td class="string">web-components</td><td class="string">web-vitals</td><td class="string">perpetual</td><td class="string">material</td><td class="string">Apache-2.0</td><td class="string">git+https://github.com/GoogleChrome/web-vitals.git</td><td class="string">3.5.2</td><td class="string">3.5.2</td><td class="string">^3.5.2</td><td class="string">Philip Walton philip@philipwalton.com http://philipwalton.com</td></tr></tbody></table>
52
52
  </body>
53
53
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terraware/web-components",
3
- "version": "4.3.3",
3
+ "version": "5.0.0",
4
4
  "author": "Terraformation Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -24,6 +24,7 @@
24
24
  "@mui/x-date-pickers": "^7.22.0",
25
25
  "@playcanvas/react": "0.11.5",
26
26
  "classnames": "^2.3.2",
27
+ "csv-parse": "^5.5.5",
27
28
  "geojson": "^0.5.0",
28
29
  "luxon": "^3.3.0",
29
30
  "marked": "^16.2.1",
@@ -0,0 +1,50 @@
1
+ key_name,en,comment
2
+ ADD_ANNOTATION,Add Annotation,
3
+ ANNOTATION_DESCRIPTION_TOOLTIP,Additional details or context about this annotation,
4
+ ANNOTATION_LABEL_TOOLTIP,Short identifier displayed on the annotation hotspot,
5
+ ANNOTATION_TITLE_TOOLTIP,Main heading for the annotation,
6
+ ANNOTATIONS,Annotations,
7
+ AR,AR,Augmented Reality
8
+ ARROW_KEYS,Arrow Keys,
9
+ AUTO_ROTATE,Auto Rotate,
10
+ BOUNDED_FLY,Bounded-fly,
11
+ CAMERA_FOCUS_POINT,Focus Point,
12
+ CAMERA_INFO,Camera Info,
13
+ CAMERA_POSITION,Position,
14
+ CANCEL,Cancel,
15
+ CHOOSE_FILE,Choose File...,
16
+ CONTROLS,Controls,
17
+ CTRL,Ctrl,
18
+ DELETE_ANNOTATION,Delete Annotation,
19
+ DESCRIPTION,Description,
20
+ DESELECT_ANNOTATION,Deselect Annotation,
21
+ EDIT,Edit,
22
+ EDIT_ANNOTATION,Edit Annotation,
23
+ EXISTING,Existing,
24
+ FILE_SELECTED,File Selected,
25
+ FLY,Fly,
26
+ FLY_FASTER,Fly faster,
27
+ FLY_SLOWER,Fly slower,
28
+ FREE_FLY,Free-fly,
29
+ IMAGES,Images,
30
+ LABEL,Label,
31
+ LEFT_MOUSE,Left Mouse,
32
+ LOOK,Look,
33
+ MIDDLE_MOUSE,Middle Mouse,
34
+ MOUSE_WHEEL,Mouse Wheel,
35
+ NEW,New,
36
+ ORBIT,Orbit,
37
+ PAN,Pan,
38
+ PINCH,Pinch,
39
+ REPLACE_FILE,Replace File...,
40
+ RESET_CAMERA,Reset Camera,
41
+ RIGHT_MOUSE,Right Mouse,
42
+ SAVE,Save,
43
+ SHIFT,Shift,
44
+ SWIPE,Swipe,
45
+ TITLE,Title,
46
+ TOUCH_DRAG,Touch + Drag,
47
+ UPLOAD_FILES,Upload Files,
48
+ UPLOAD_FILES_DESCRIPTION,Browse or drag and drop files.,
49
+ VR,VR,Virtual Reality
50
+ ZOOM,Zoom,
@@ -0,0 +1,50 @@
1
+ Key,Text,Hash
2
+ ADD_ANNOTATION,Agregar anotación,91742a0f
3
+ ANNOTATION_DESCRIPTION_TOOLTIP,Detalles o contexto adicional sobre esta anotación,8cb997d2
4
+ ANNOTATION_LABEL_TOOLTIP,Identificador breve que se muestra en el punto destacado de la anotación,adbb02a1
5
+ ANNOTATION_TITLE_TOOLTIP,Título principal de la anotación,b3f5b753
6
+ ANNOTATIONS,Anotaciones,c15a3aa4
7
+ AR,RA,25a8e55a
8
+ ARROW_KEYS,Flechas del teclado,5cefb475
9
+ AUTO_ROTATE,Rotación automática,15ce1a40
10
+ BOUNDED_FLY,Vuelo delimitado,9e3c46ae
11
+ CAMERA_FOCUS_POINT,Punto de enfoque,350a921b
12
+ CAMERA_INFO,Información de la cámara,4283d43c
13
+ CAMERA_POSITION,Posición,3eb30313
14
+ CANCEL,Cancelar,e73dc4d4
15
+ CHOOSE_FILE,Seleccione archivo...,967c4c38
16
+ CONTROLS,Controles,f7c1294f
17
+ CTRL,Ctrl,f485607a
18
+ DELETE_ANNOTATION,Eliminar anotación,10fcdc4e
19
+ DESCRIPTION,Descripción,9cb0cc64
20
+ DESELECT_ANNOTATION,Deseleccionar anotación,32c46edd
21
+ EDIT,Editar,9d1278d8
22
+ EDIT_ANNOTATION,Editar anotación,82bcb054
23
+ EXISTING,Existente,fa67ac1d
24
+ FILE_SELECTED,Archivo seleccionado,23a60a8d
25
+ FLY,Volar,0747d35f
26
+ FLY_FASTER,Volar más rápido,e24d00c8
27
+ FLY_SLOWER,Volar más lento,0271712f
28
+ FREE_FLY,Vuelo libre,3eb18bf0
29
+ IMAGES,Imágenes,2041d3b6
30
+ LABEL,Etiqueta,85def946
31
+ LEFT_MOUSE,Botón izquierdo del ratón,b034e4dc
32
+ LOOK,Mirar,e006bd6f
33
+ MIDDLE_MOUSE,Botón central del ratón,18763653
34
+ MOUSE_WHEEL,Rueda del ratón,8e3d3d78
35
+ NEW,Nuevo,b8096e3b
36
+ ORBIT,Orbitar,8e3af3cb
37
+ PAN,Desplazar,34177007
38
+ PINCH,Pellizcar,3c1f1f79
39
+ REPLACE_FILE,Reemplazar archivo...,14c3cc45
40
+ RESET_CAMERA,Restablecer cámara,ee37fbd5
41
+ RIGHT_MOUSE,Botón derecho del ratón,d551c809
42
+ SAVE,Guardar,526a3e42
43
+ SHIFT,Shift,4d173d2a
44
+ SWIPE,Deslizar,bc0962fa
45
+ TITLE,Título,a5f8fc0b
46
+ TOUCH_DRAG,Tocar y arrastrar,ff6d48d2
47
+ UPLOAD_FILES,Subir archivos,b98547be
48
+ UPLOAD_FILES_DESCRIPTION,Buscar o arrastrar y soltar archivos.,7c4a7822
49
+ VR,RV,98fd7fc5
50
+ ZOOM,Acercar/alejar,07b636df
@@ -0,0 +1,50 @@
1
+ Key,Text,Hash
2
+ ADD_ANNOTATION,Ajouter une annotation,91742a0f
3
+ ANNOTATION_DESCRIPTION_TOOLTIP,Détails ou contexte supplémentaires concernant cette annotation,8cb997d2
4
+ ANNOTATION_LABEL_TOOLTIP,Identifiant court affiché sur le point d’annotation,adbb02a1
5
+ ANNOTATION_TITLE_TOOLTIP,Titre principal de l’annotation,b3f5b753
6
+ ANNOTATIONS,Annotations,c15a3aa4
7
+ AR,RA,25a8e55a
8
+ ARROW_KEYS,Touches fléchées,5cefb475
9
+ AUTO_ROTATE,Rotation automatique,15ce1a40
10
+ BOUNDED_FLY,Vol limité,9e3c46ae
11
+ CAMERA_FOCUS_POINT,Point de mise au point,350a921b
12
+ CAMERA_INFO,Informations sur la caméra,4283d43c
13
+ CAMERA_POSITION,Position,3eb30313
14
+ CANCEL,Annuler,e73dc4d4
15
+ CHOOSE_FILE,Choisissez le fichier...,967c4c38
16
+ CONTROLS,Commandes,f7c1294f
17
+ CTRL,Ctrl,f485607a
18
+ DELETE_ANNOTATION,Supprimer l’annotation,10fcdc4e
19
+ DESCRIPTION,Description,9cb0cc64
20
+ DESELECT_ANNOTATION,Désélectionner l’annotation,32c46edd
21
+ EDIT,Modifier,9d1278d8
22
+ EDIT_ANNOTATION,Modifier l’annotation,82bcb054
23
+ EXISTING,Existant,fa67ac1d
24
+ FILE_SELECTED,Fichier sélectionné,23a60a8d
25
+ FLY,Voler,0747d35f
26
+ FLY_FASTER,Voler plus vite,e24d00c8
27
+ FLY_SLOWER,Voler plus lentement,0271712f
28
+ FREE_FLY,Vol libre,3eb18bf0
29
+ IMAGES,Images,2041d3b6
30
+ LABEL,Étiquette,85def946
31
+ LEFT_MOUSE,Bouton gauche de la souris,b034e4dc
32
+ LOOK,Regarder,e006bd6f
33
+ MIDDLE_MOUSE,Bouton central de la souris,18763653
34
+ MOUSE_WHEEL,Molette de la souris,8e3d3d78
35
+ NEW,Nouveau,b8096e3b
36
+ ORBIT,Orbiter,8e3af3cb
37
+ PAN,Déplacer,34177007
38
+ PINCH,Pincer,3c1f1f79
39
+ REPLACE_FILE,Remplacer le fichier...,14c3cc45
40
+ RESET_CAMERA,Réinitialiser la caméra,ee37fbd5
41
+ RIGHT_MOUSE,Bouton droit de la souris,d551c809
42
+ SAVE,Sauvegarder,526a3e42
43
+ SHIFT,Maj,4d173d2a
44
+ SWIPE,Glisser,bc0962fa
45
+ TITLE,Titre,a5f8fc0b
46
+ TOUCH_DRAG,Toucher + Glisser,ff6d48d2
47
+ UPLOAD_FILES,Téléverser des fichiers,b98547be
48
+ UPLOAD_FILES_DESCRIPTION,Parcourir ou glisser-déposer des fichiers.,7c4a7822
49
+ VR,RV,98fd7fc5
50
+ ZOOM,Zoom,07b636df
@@ -0,0 +1,14 @@
1
+ Here's a list of translations to use for specific terminology. Use these translations consistently.
2
+ It is okay to change these terms to different parts of speech if needed to maintain grammatical
3
+ correctness, but don't choose totally different words.
4
+
5
+ annotation: anotación
6
+ augmented reality (AR): realidad aumentada (RA)
7
+ camera: cámara
8
+ focus point: punto de enfoque
9
+ fly: volar
10
+ hotspot: punto destacado
11
+ mouse: ratón
12
+ orbit: orbitar
13
+ pan: desplazar
14
+ virtual reality (VR): realidad virtual (RV)
@@ -0,0 +1,14 @@
1
+ Here's a list of translations to use for specific terminology. Use these translations consistently.
2
+ It is okay to change these terms to different parts of speech if needed to maintain grammatical
3
+ correctness, but don't choose totally different words.
4
+
5
+ annotation: annotation
6
+ augmented reality (AR): réalité augmentée (RA)
7
+ camera: caméra
8
+ focus point: point de mise au point
9
+ fly: voler
10
+ hotspot: point d'annotation
11
+ mouse: souris
12
+ orbit: orbiter
13
+ pan: déplacer
14
+ virtual reality (VR): réalité virtuelle (RV)
@@ -0,0 +1,13 @@
1
+ Some notes about language style:
2
+
3
+ - The words "Terraformation" and "Terraware" should not be translated and should be capitalized.
4
+ - The tone of the translations should be formal but not stuffy. Address the user as if they're a
5
+ customer or business associate, not as if they're a friend.
6
+ - These strings label controls in a shared component library, mostly the 3D virtual walkthrough
7
+ viewer. Many are short button labels or tooltips, so prefer concise translations that will fit in
8
+ a small control; a translation two or three times longer than the English will overflow its
9
+ button.
10
+ - Input device names ("Left Mouse", "Mouse Wheel", "Arrow Keys") and gestures ("Pinch", "Swipe")
11
+ should use whatever terms the platform conventionally uses in that language.
12
+ - Modifier key names ("Shift", "Ctrl") should match the labels printed on keyboards sold for that
13
+ language, which often means leaving them untranslated.
@@ -0,0 +1,36 @@
1
+ export type StringsMap = Record<string, string>;
2
+ /**
3
+ * Loads a CSV strings file into an object, taking keys and values from the first two columns.
4
+ */
5
+ export declare const csvToStrings: (csvData: string) => StringsMap;
6
+ /**
7
+ * Renders a strings object as a TypeScript module that exports a constant called "strings",
8
+ * formatted the way the repository's Prettier configuration wants it so that generating a table and
9
+ * formatting the tree don't fight over the result.
10
+ */
11
+ export declare const stringsToTypeScript: (stringsMap: StringsMap, targetPath: string) => Promise<string>;
12
+ /**
13
+ * Transforms the English strings table into gibberish, which makes untranslated text obvious
14
+ * without waiting on a translation.
15
+ *
16
+ * 1. Split the English string into whitespace-delimited words.
17
+ * 2. Reverse the order of the words.
18
+ * 3. Render each word as a base64 encoding of its UTF-8 representation, except for words that look
19
+ * like format string placeholders.
20
+ */
21
+ export declare const generateGibberish: (english: StringsMap) => StringsMap;
22
+ /**
23
+ * Converts a CSV strings file to a TypeScript source file that exports a constant called "strings".
24
+ * This will be an object that has the same keys as the English strings file; the English strings
25
+ * will be used for any keys that aren't translated yet.
26
+ *
27
+ * The filename is assumed to be the locale code with a ".csv" suffix. Converting the English file
28
+ * also writes the gibberish table, which is derived from English rather than translated.
29
+ */
30
+ export declare const convertCsvFile: (csvPath: string, targetDir: string, defaultToEnglish?: boolean) => Promise<void>;
31
+ /**
32
+ * Converts the CSV files for all locales to TypeScript source files. The list of locales is
33
+ * determined by the presence of CSV files.
34
+ */
35
+ export declare const convertAllLocales: (csvDir: string, stringsDir: string, defaultToEnglish?: boolean) => Promise<string[]>;
36
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/strings/export.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAIhD;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,UAe9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAU,YAAY,UAAU,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,MAAM,CAKpG,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,UAAU,KAAG,UAUrD,CAAC;AA2BJ;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAU,SAAS,MAAM,EAAE,WAAW,MAAM,EAAE,0BAAuB,KAAG,OAAO,CAAC,IAAI,CAqB9G,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EACd,YAAY,MAAM,EAClB,0BAAuB,KACtB,OAAO,CAAC,MAAM,EAAE,CAQlB,CAAC"}
@@ -0,0 +1,116 @@
1
+ import { parse } from 'csv-parse/sync';
2
+ import { readdir, readFile, writeFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { resolveConfig, format } from 'prettier';
5
+
6
+ /**
7
+ * Renders the CSV string tables as TypeScript source.
8
+ *
9
+ * This runs at build time, not at runtime. Nothing in the component runtime imports it, so its Node
10
+ * and CSV dependencies never reach a browser bundle. It's published rather than kept in scripts/ so
11
+ * that applications sharing these string tables can drive the same conversion.
12
+ */
13
+ const GENERATED_HEADER = '/* Generated from the CSV files in csv/ by `yarn generate-strings`. Do not edit. */';
14
+
15
+ /**
16
+ * Loads a CSV strings file into an object, taking keys and values from the first two columns.
17
+ */
18
+ const csvToStrings = csvData => {
19
+ const rows = parse(csvData, {
20
+ // Skip header row
21
+ from: 2,
22
+ // Only rows for strings that have comments have 3 fields.
23
+ relax_column_count_less: true,
24
+ // Skip empty "row" that is really just the terminating linefeed
25
+ skip_empty_lines: true
26
+ });
27
+ return rows.reduce((result, row) => {
28
+ result[row[0]] = row[1];
29
+ return result;
30
+ }, {});
31
+ };
32
+
33
+ /**
34
+ * Renders a strings object as a TypeScript module that exports a constant called "strings",
35
+ * formatted the way the repository's Prettier configuration wants it so that generating a table and
36
+ * formatting the tree don't fight over the result.
37
+ */
38
+ const stringsToTypeScript = async (stringsMap, targetPath) => {
39
+ const source = `${GENERATED_HEADER}\nexport const strings = ${JSON.stringify(stringsMap, null, 2)};\n`;
40
+ const prettierConfig = await resolveConfig(targetPath);
41
+ return format(source, {
42
+ ...prettierConfig,
43
+ filepath: targetPath
44
+ });
45
+ };
46
+
47
+ /**
48
+ * Transforms the English strings table into gibberish, which makes untranslated text obvious
49
+ * without waiting on a translation.
50
+ *
51
+ * 1. Split the English string into whitespace-delimited words.
52
+ * 2. Reverse the order of the words.
53
+ * 3. Render each word as a base64 encoding of its UTF-8 representation, except for words that look
54
+ * like format string placeholders.
55
+ */
56
+ const generateGibberish = english => Object.fromEntries(Object.entries(english).map(([key, value]) => [key, value.split(' ').reverse().map(word => word.startsWith('{') ? word : Buffer.from(word, 'utf-8').toString('base64').replace(/=/g, '')).join(' ')]));
57
+ const exportStrings = async (englishStrings, localizedStrings, locale, targetDir, defaultToEnglish) => {
58
+ const stringsMap = {};
59
+ for (const key of Object.keys(englishStrings)) {
60
+ if (key in localizedStrings) {
61
+ stringsMap[key] = localizedStrings[key];
62
+ } else {
63
+ console.warn(`Locale ${locale} has no translation for ${key}`);
64
+ if (defaultToEnglish) {
65
+ stringsMap[key] = englishStrings[key];
66
+ }
67
+ }
68
+ }
69
+ const targetPath = path.resolve(targetDir, `strings-${locale}.ts`);
70
+ await writeFile(targetPath, await stringsToTypeScript(stringsMap, targetPath), {
71
+ encoding: 'utf-8'
72
+ });
73
+ };
74
+
75
+ /**
76
+ * Converts a CSV strings file to a TypeScript source file that exports a constant called "strings".
77
+ * This will be an object that has the same keys as the English strings file; the English strings
78
+ * will be used for any keys that aren't translated yet.
79
+ *
80
+ * The filename is assumed to be the locale code with a ".csv" suffix. Converting the English file
81
+ * also writes the gibberish table, which is derived from English rather than translated.
82
+ */
83
+ const convertCsvFile = async (csvPath, targetDir, defaultToEnglish = true) => {
84
+ if (!csvPath.endsWith('.csv')) {
85
+ throw new Error('Cannot convert a non-CSV file');
86
+ }
87
+ const locale = path.basename(csvPath, '.csv');
88
+ const stringsMap = csvToStrings(await readFile(csvPath, {
89
+ encoding: 'utf-8'
90
+ }));
91
+ let englishStringsMap;
92
+ if (locale === 'en') {
93
+ englishStringsMap = stringsMap;
94
+ } else {
95
+ const englishPath = path.resolve(path.dirname(csvPath), 'en.csv');
96
+ englishStringsMap = csvToStrings(await readFile(englishPath, {
97
+ encoding: 'utf-8'
98
+ }));
99
+ }
100
+ await exportStrings(englishStringsMap, stringsMap, locale, targetDir, defaultToEnglish);
101
+ if (locale === 'en') {
102
+ await exportStrings(englishStringsMap, generateGibberish(englishStringsMap), 'gx', targetDir, defaultToEnglish);
103
+ }
104
+ };
105
+
106
+ /**
107
+ * Converts the CSV files for all locales to TypeScript source files. The list of locales is
108
+ * determined by the presence of CSV files.
109
+ */
110
+ const convertAllLocales = async (csvDir, stringsDir, defaultToEnglish = true) => {
111
+ const csvFiles = (await readdir(csvDir)).filter(filename => filename.endsWith('.csv'));
112
+ await Promise.all(csvFiles.map(filename => convertCsvFile(path.join(csvDir, filename), stringsDir, defaultToEnglish)));
113
+ return csvFiles;
114
+ };
115
+
116
+ export { convertAllLocales, convertCsvFile, csvToStrings, generateGibberish, stringsToTypeScript };
@@ -0,0 +1,22 @@
1
+ import { strings as en } from './strings-en';
2
+ /**
3
+ * The set of strings every locale provides. The English table is the source of truth for the list
4
+ * of keys.
5
+ */
6
+ export type ComponentStrings = typeof en;
7
+ /**
8
+ * Sets the locale these components render in. Consumers own the locale -- a component library has
9
+ * no reliable way to know whether the browser's language or a user's profile setting should win --
10
+ * so nothing here changes until an application calls this. Accepts a bare language tag or one with
11
+ * a region ('es' or 'es-MX').
12
+ */
13
+ export declare const setLocale: (locale: string) => void;
14
+ /** The resolved locale, which is also the locale to hand to Intl and other formatters. */
15
+ export declare const getLocale: () => string;
16
+ /**
17
+ * The current string table. For components, prefer `useStrings`, which re-renders on a locale
18
+ * change; this is for the imperative code that can't hold a hook, such as PlayCanvas scripts.
19
+ */
20
+ export declare const getStrings: () => ComponentStrings;
21
+ export declare const useStrings: () => ComponentStrings;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/strings/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,cAAc,CAAC;AAK7C;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,EAAE,CAAC;AAgBzC;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,KAAG,IAS1C,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,SAAS,QAAO,MAAuB,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAO,gBAAkC,CAAC;AAUjE,eAAO,MAAM,UAAU,QAAO,gBAA2E,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { useSyncExternalStore } from 'react';
2
+ import { findLocaleDetails, supportedLocales } from './locales.js';
3
+ import { strings } from './strings-en.js';
4
+ import { strings as strings$3 } from './strings-es.js';
5
+ import { strings as strings$2 } from './strings-fr.js';
6
+ import { strings as strings$1 } from './strings-gx.js';
7
+
8
+ /**
9
+ * The set of strings every locale provides. The English table is the source of truth for the list
10
+ * of keys.
11
+ */
12
+
13
+ const tables = {
14
+ en: strings,
15
+ es: strings$3,
16
+ fr: strings$2,
17
+ gx: strings$1
18
+ };
19
+
20
+ /**
21
+ * Locales we have a bundled string table for. A locale can be supported -- listed in a locale
22
+ * selector -- before its table lands, and resolving against the tables we actually have keeps
23
+ * `getLocale` and `getStrings` describing the same language.
24
+ */
25
+ const localesWithTables = () => supportedLocales.filter(locale => locale.id in tables);
26
+ let currentLocale = 'en';
27
+ let currentStrings = strings;
28
+ const listeners = new Set();
29
+
30
+ /**
31
+ * Sets the locale these components render in. Consumers own the locale -- a component library has
32
+ * no reliable way to know whether the browser's language or a user's profile setting should win --
33
+ * so nothing here changes until an application calls this. Accepts a bare language tag or one with
34
+ * a region ('es' or 'es-MX').
35
+ */
36
+ const setLocale = locale => {
37
+ const resolved = findLocaleDetails(localesWithTables(), locale).id;
38
+ if (resolved === currentLocale) {
39
+ return;
40
+ }
41
+ currentLocale = resolved;
42
+ currentStrings = tables[resolved] ?? strings;
43
+ listeners.forEach(notify => notify());
44
+ };
45
+
46
+ /** The resolved locale, which is also the locale to hand to Intl and other formatters. */
47
+ const getLocale = () => currentLocale;
48
+
49
+ /**
50
+ * The current string table. For components, prefer `useStrings`, which re-renders on a locale
51
+ * change; this is for the imperative code that can't hold a hook, such as PlayCanvas scripts.
52
+ */
53
+ const getStrings = () => currentStrings;
54
+ const subscribe = notify => {
55
+ listeners.add(notify);
56
+ return () => {
57
+ listeners.delete(notify);
58
+ };
59
+ };
60
+ const useStrings = () => useSyncExternalStore(subscribe, getStrings, getStrings);
61
+
62
+ export { getLocale, getStrings, setLocale, useStrings };
@@ -0,0 +1,38 @@
1
+ export interface LocaleDetails {
2
+ /**
3
+ * Locale identifier. This must start with a language tag (2 or 3 letters) and may optionally
4
+ * have a hyphen and a location code. For example, 'en' or 'en-US'.
5
+ */
6
+ id: string;
7
+ /**
8
+ * Name of the locale as it appears in a locale selector. This will typically be the name of the
9
+ * locale in whatever language the locale uses. That is, 'Español' and not 'Spanish'.
10
+ */
11
+ name: string;
12
+ /**
13
+ * Whether this locale is in development and not ready for production.
14
+ */
15
+ inDevelopment?: boolean;
16
+ }
17
+ /** Supported locales in the order they should appear in a locale selector. */
18
+ export declare const supportedLocales: LocaleDetails[];
19
+ /**
20
+ * Returns the locales that should be offered to users. Locales still in development are left out
21
+ * unless they're asked for, which is how a consumer exposes them outside of production.
22
+ */
23
+ export declare const getSupportedLocales: (includeInDevelopment?: boolean) => LocaleDetails[];
24
+ /**
25
+ * Returns the locale from a list of locales that matches the user's selected language.
26
+ *
27
+ * The user's locale can include both a language and a country code, but entries in a list of
28
+ * languages usually don't have country codes. So we need to find the entry that is the longest
29
+ * prefix of the user's locale.
30
+ *
31
+ * If the locale is es-MX and the list of locales only has es, we want the es item to be selected.
32
+ * But if the locale is zh-CN and the list has both zh-CN and zh-TW, we want zh-CN to be selected.
33
+ *
34
+ * If none of the locales in the list matches, returns the first locale from the list. The list
35
+ * must not be empty.
36
+ */
37
+ export declare const findLocaleDetails: (locales: LocaleDetails[], locale: string) => LocaleDetails;
38
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../src/strings/locales.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,aAAa,EAK3C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,8BAA4B,KAAG,aAAa,EACsB,CAAC;AAEvG;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,aAAa,EAAE,EAAE,QAAQ,MAAM,KAAG,aAQ1E,CAAC"}
@@ -0,0 +1,42 @@
1
+ /** Supported locales in the order they should appear in a locale selector. */
2
+ const supportedLocales = [{
3
+ id: 'en',
4
+ name: 'English'
5
+ }, {
6
+ id: 'es',
7
+ name: 'Español'
8
+ }, {
9
+ id: 'fr',
10
+ name: 'Français'
11
+ }, {
12
+ id: 'gx',
13
+ name: 'Gibberish',
14
+ inDevelopment: true
15
+ }];
16
+
17
+ /**
18
+ * Returns the locales that should be offered to users. Locales still in development are left out
19
+ * unless they're asked for, which is how a consumer exposes them outside of production.
20
+ */
21
+ const getSupportedLocales = (includeInDevelopment = false) => includeInDevelopment ? supportedLocales : supportedLocales.filter(locale => !locale.inDevelopment);
22
+
23
+ /**
24
+ * Returns the locale from a list of locales that matches the user's selected language.
25
+ *
26
+ * The user's locale can include both a language and a country code, but entries in a list of
27
+ * languages usually don't have country codes. So we need to find the entry that is the longest
28
+ * prefix of the user's locale.
29
+ *
30
+ * If the locale is es-MX and the list of locales only has es, we want the es item to be selected.
31
+ * But if the locale is zh-CN and the list has both zh-CN and zh-TW, we want zh-CN to be selected.
32
+ *
33
+ * If none of the locales in the list matches, returns the first locale from the list. The list
34
+ * must not be empty.
35
+ */
36
+ const findLocaleDetails = (locales, locale) => locales.reduce((bestMatch, candidate) =>
37
+ // The best match so far is only worth keeping if it's a prefix of the requested locale too.
38
+ // reduce() seeds with the first locale without checking it, so a leading 'en-US' would
39
+ // otherwise be treated as a match for 'en' and never replaced.
40
+ locale.startsWith(candidate.id) && (!locale.startsWith(bestMatch.id) || candidate.id.length > bestMatch.id.length) ? candidate : bestMatch);
41
+
42
+ export { findLocaleDetails, getSupportedLocales, supportedLocales };