Skip to content

Commit

Permalink
Fixed 'snips' and 'snippetToText', as well as some README stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
turnerhayes committed Nov 25, 2018
1 parent 0bfad93 commit 4d5285c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ In the future, this tool could let users try out changes in multiple life circum

### G2. Translation objects

Translation objects are the way we're working on making the app translatable. As you can see, they have version numbers in the language files. When big changes are made to an English translation object, we bump up that translation object's version number. We then use that to be able to tell what snippets are out of date in other languages. If a translation object is out of date in another language, the app uses the English translation object by default. When another language's translation object is brought up-to-date with the English one, its version number is updated and it will be used in the app again.
Translation objects are the way we're working on making the app translatable. As you can see, they have version numbers in the language files. When big changes are made to an English translation object, we bump up that translation object's version number. We then use that to be able to tell what translation objects are out of date in other languages. If a translation object is out of date in another language, the app uses the English translation object by default. When another language's translation object is brought up-to-date with the English one, its version number is updated and it will be used in the app again.

When the code preps the snippets for the app, though, it gets rid of the version numbers so that it'll be easier to maintain the code as snippets change. Because we don't want the key name change to be invisible, we decided to add `i_` to the beginning of the translation object. That way a person new to the project can at least see that the weirdness is deliberate and can easily search the code for `i_` to find the source.
When the code preps the translation objects for the app, though, it gets rid of the version numbers so that it'll be easier to maintain the code as translation objects change. Because we don't want the key name change to be invisible, we decided to add `i_` to the beginning of the translation object. That way a person new to the project can at least see that the weirdness is deliberate and can easily search the code for `i_` to find the source.

There's a wiki page in the works about the flow of editing translation object files, since we use google docs to allow non-coders to edit the translations.

Expand Down
8 changes: 4 additions & 4 deletions src/components/dev/DevHud.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const DevMenu = function ({ devProps, funcs, data, state }) {
langOpts = [];

for (let key in langs) {
let snips = langs[ key ],
let translations = langs[ key ],
lang = {
text: snips.langName,
key: snips.langCode,
value: snips.langCode,
text: translations.langName,
key: translations.langCode,
value: translations.langCode,
};
langOpts.push(lang);
}
Expand Down
6 changes: 3 additions & 3 deletions src/forms/output/BenefitsLines.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getChartData } from '../../utils/charts/getChartData';
import { toFancyMoneyStr } from '../../utils/charts/chartFormatting';
import {
formatMoneyWithK,
snippetToText,
textFromTranslatedElement,
} from './chartStringTransformers';
import { zoom } from './zoom';

Expand Down Expand Up @@ -50,7 +50,7 @@ class BenefitsLinesComp extends Component {

constructor (props) {
super(props);
let separator = snippetToText(props.translations.i_thousandsSeparator);
let separator = textFromTranslatedElement(props.translations.i_thousandsSeparator);
// This doesn't affect the strings we put in there, just pure numbers
Highcharts.setOptions({ lang: { thousandsSep: separator }});

Expand Down Expand Up @@ -84,7 +84,7 @@ class BenefitsLinesComp extends Component {
const multiplier = multipliers[ timescale ],
resources = activePrograms,
currentEarned = client.current.earned * multiplier,
getText = snippetToText;
getText = textFromTranslatedElement;

// Adjust to time-interval. Highcharts will round
// for displayed ticks.
Expand Down
6 changes: 3 additions & 3 deletions src/forms/output/ResourcesColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { getChartData } from '../../utils/charts/getChartData';
import { toFancyMoneyStr } from '../../utils/charts/chartFormatting';
import {
formatMoneyWithK,
snippetToText,
textFromTranslatedElement,
} from './chartStringTransformers';


Expand All @@ -44,7 +44,7 @@ class ResourcesColumnsComp extends Component {

constructor (props) {
super(props);
let separator = snippetToText(props.translations.i_thousandsSeparator);
let separator = textFromTranslatedElement(props.translations.i_thousandsSeparator);
// This doesn't affect the strings we put in there, just pure numbers
Highcharts.setOptions({ lang: { thousandsSep: separator }});
}
Expand All @@ -64,7 +64,7 @@ class ResourcesColumnsComp extends Component {
resources = [ `earned` ].concat(activePrograms),
currentEarned = client.current.earned * multiplier,
futureEarned = client.future.earned * multiplier,
getText = snippetToText;
getText = textFromTranslatedElement;

// Adjust to time-interval. Highcharts will round
// for displayed ticks.
Expand Down
6 changes: 3 additions & 3 deletions src/forms/output/StackedResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getChartData } from '../../utils/charts/getChartData';
import { toFancyMoneyStr } from '../../utils/charts/chartFormatting';
import {
formatMoneyWithK,
snippetToText,
textFromTranslatedElement,
} from './chartStringTransformers';
import { zoom } from './zoom';

Expand Down Expand Up @@ -55,7 +55,7 @@ class StackedResourcesComp extends Component {

constructor (props) {
super(props);
let separator = snippetToText(props.translations.i_thousandsSeparator);
let separator = textFromTranslatedElement(props.translations.i_thousandsSeparator);
// This doesn't affect the strings we put in there, just pure numbers
Highcharts.setOptions({ lang: { thousandsSep: separator }});

Expand Down Expand Up @@ -89,7 +89,7 @@ class StackedResourcesComp extends Component {
const multiplier = multipliers[ timescale ],
resources = [ `earned` ].concat(activePrograms),
currentEarned = client.current.earned * multiplier,
getText = snippetToText;
getText = textFromTranslatedElement;

// Adjust to time-interval. Highcharts will round
// for displayed ticks.
Expand Down
10 changes: 5 additions & 5 deletions src/forms/output/chartStringTransformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @returns {string}
*/
const snippetToText = function (translationObj) {
const textFromTranslatedElement = function (translationObj) {

const children = translationObj.props.children;

Expand All @@ -23,7 +23,7 @@ const snippetToText = function (translationObj) {

let allText = ``;
for (let child of children) {
allText += ` ` + snippetToText(child);
allText += ` ` + textFromTranslatedElement(child);
}

return allText;
Expand All @@ -50,8 +50,8 @@ const snippetToText = function (translationObj) {
* // <span class="graph-label">10k$</span>
*/
const formatMoneyWithK = (chartObject, translations) => {
const before = snippetToText(translations.i_beforeMoney),
after = snippetToText(translations.i_afterMoney),
const before = textFromTranslatedElement(translations.i_beforeMoney),
after = textFromTranslatedElement(translations.i_afterMoney),
// https://api.highcharts.com/highcharts/xAxis.labels.formatter
withMoney = before + chartObject.axis.defaultLabelFormatter.call(chartObject) + after,
asHTML = `<span class="graph-label">${withMoney}</span>`;
Expand All @@ -61,5 +61,5 @@ const formatMoneyWithK = (chartObject, translations) => {

export {
formatMoneyWithK,
snippetToText,
textFromTranslatedElement,
};

0 comments on commit 4d5285c

Please sign in to comment.