Skip to content

Commit

Permalink
Update several localization strings
Browse files Browse the repository at this point in the history
- This switches from the older way of doing plural "single"/"multi" to the
  standard `Intl.PluralRules` way supported by Transifex "one"/"other"
- Also adds a lot of Developer Notes to the translator file for the
  walkthrough stings - these will be shown as instructions for translators
  • Loading branch information
bhousel committed Dec 12, 2024
1 parent 60be1be commit 41bbbcc
Show file tree
Hide file tree
Showing 12 changed files with 439 additions and 437 deletions.
591 changes: 297 additions & 294 deletions data/core.yaml

Large diffs are not rendered by default.

222 changes: 113 additions & 109 deletions data/l10n/core.en.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions modules/operations/circularize.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function operationCircularize(context, selectedIDs) {
const storage = context.systems.storage;
const viewport = context.viewport;

const multi = selectedIDs.length === 1 ? 'single' : 'multiple';
const entities = selectedIDs.map(entityID => graph.hasEntity(entityID)).filter(Boolean);
const isNew = entities.every(entity => entity.isNew());
const extent = utilTotalExtent(entities, graph);
Expand Down Expand Up @@ -97,8 +96,8 @@ export function operationCircularize(context, selectedIDs) {
operation.tooltip = function() {
const disabledReason = operation.disabled();
return disabledReason ?
l10n.t(`operations.circularize.${disabledReason}.${multi}`) :
l10n.t(`operations.circularize.description.${multi}`);
l10n.t(`operations.circularize.${disabledReason}`, { n: selectedIDs.length }) :
l10n.t(`operations.circularize.description`, { n: selectedIDs.length });
};


Expand Down
5 changes: 2 additions & 3 deletions modules/operations/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export function operationDelete(context, selectedIDs) {
const storage = context.systems.storage;
const viewport = context.viewport;

const multi = selectedIDs.length === 1 ? 'single' : 'multiple';
const entities = selectedIDs.map(entityID => graph.hasEntity(entityID)).filter(Boolean);
const isNew = entities.every(entity => entity.isNew());
const action = actionDeleteMultiple(selectedIDs);
Expand Down Expand Up @@ -144,8 +143,8 @@ export function operationDelete(context, selectedIDs) {
operation.tooltip = function() {
const disabledReason = operation.disabled();
return disabledReason ?
l10n.t(`operations.delete.${disabledReason}.${multi}`) :
l10n.t(`operations.delete.description.${multi}`);
l10n.t(`operations.delete.${disabledReason}`, { n: selectedIDs.length }) :
l10n.t(`operations.delete.description`, { n: selectedIDs.length });
};


Expand Down
3 changes: 1 addition & 2 deletions modules/operations/downgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export function operationDowngrade(context, selectedIDs) {

let _affectedFeatureCount = 0;
let _downgradeType = downgradeTypeForEntityIDs(selectedIDs);
const multi = _affectedFeatureCount === 1 ? 'single' : 'multiple';


function downgradeTypeForEntityIDs(entityIDs) {
Expand Down Expand Up @@ -117,7 +116,7 @@ export function operationDowngrade(context, selectedIDs) {
operation.tooltip = function () {
const disabledReason = operation.disabled();
return disabledReason ?
l10n.t(`operations.downgrade.${disabledReason}.${multi}`) :
l10n.t(`operations.downgrade.${disabledReason}`, { n: _affectedFeatureCount }) :
l10n.t(`operations.downgrade.description.${_downgradeType}`);
};

Expand Down
5 changes: 2 additions & 3 deletions modules/operations/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function operationExtract(context, selectedIDs) {
const storage = context.systems.storage;
const viewport = context.viewport;

const multi = selectedIDs.length === 1 ? 'single' : 'multiple';
const entities = selectedIDs.map(entityID => graph.hasEntity(entityID)).filter(Boolean);
const isNew = entities.every(entity => entity.isNew());
const extent = utilTotalExtent(entities, graph);
Expand Down Expand Up @@ -100,8 +99,8 @@ export function operationExtract(context, selectedIDs) {
operation.tooltip = function () {
const disabledReason = operation.disabled();
return disabledReason ?
l10n.t(`operations.extract.${disabledReason}.${multi}`) :
l10n.t(`operations.extract.description.${geometryType}.${multi}`);
l10n.t(`operations.extract.${disabledReason}`, { n: selectedIDs.length }) :
l10n.t(`operations.extract.description.${geometryType}`, { n: selectedIDs.length });
};


Expand Down
5 changes: 2 additions & 3 deletions modules/operations/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export function operationMove(context, selectedIDs) {
const storage = context.systems.storage;
const viewport = context.viewport;

const multi = selectedIDs.length === 1 ? 'single' : 'multiple';
const entities = selectedIDs.map(entityID => graph.hasEntity(entityID)).filter(Boolean);
const isNew = entities.every(entity => entity.isNew());
const nodes = utilGetAllNodes(selectedIDs, graph);
Expand Down Expand Up @@ -72,8 +71,8 @@ export function operationMove(context, selectedIDs) {
operation.tooltip = function() {
const disabledReason = operation.disabled();
return disabledReason ?
l10n.t(`operations.move.${disabledReason}.${multi}`) :
l10n.t(`operations.move.description.${multi}`);
l10n.t(`operations.move.${disabledReason}`, { n: selectedIDs.length }) :
l10n.t(`operations.move.description`, { n: selectedIDs.length });
};


Expand Down
5 changes: 2 additions & 3 deletions modules/operations/orthogonalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function operationOrthogonalize(context, selectedIDs) {
const storage = context.systems.storage;
const viewport = context.viewport;

const multi = selectedIDs.length === 1 ? 'single' : 'multiple';
const entities = selectedIDs.map(entityID => graph.hasEntity(entityID)).filter(Boolean);
const isNew = entities.every(entity => entity.isNew());
const extent = utilTotalExtent(entities, graph);
Expand Down Expand Up @@ -119,8 +118,8 @@ export function operationOrthogonalize(context, selectedIDs) {
operation.tooltip = function() {
const disabledReason = operation.disabled();
return disabledReason ?
l10n.t(`operations.orthogonalize.${disabledReason}.${multi}`) :
l10n.t(`operations.orthogonalize.description.${_type}.${multi}`);
l10n.t(`operations.orthogonalize.${disabledReason}`, { n: selectedIDs.length }) :
l10n.t(`operations.orthogonalize.description.${_type}`, { n: selectedIDs.length });
};


Expand Down
5 changes: 2 additions & 3 deletions modules/operations/reflect.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export function operationReflect(context, selectedIDs, axis = 'long') {
const storage = context.systems.storage;
const viewport = context.viewport;

const multi = selectedIDs.length === 1 ? 'single' : 'multiple';
const entities = selectedIDs.map(entityID => graph.hasEntity(entityID)).filter(Boolean);
const isNew = entities.every(entity => entity.isNew());
const extent = utilTotalExtent(entities, graph);
Expand Down Expand Up @@ -90,8 +89,8 @@ export function operationReflect(context, selectedIDs, axis = 'long') {
operation.tooltip = function() {
const disabledReason = operation.disabled();
return disabledReason ?
l10n.t(`operations.reflect.${disabledReason}.${multi}`) :
l10n.t(`operations.reflect.description.${axis}.${multi}`);
l10n.t(`operations.reflect.${disabledReason}`, { n: selectedIDs.length }) :
l10n.t(`operations.reflect.description.${axis}`, { n: selectedIDs.length });
};


Expand Down
5 changes: 2 additions & 3 deletions modules/operations/rotate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export function operationRotate(context, selectedIDs) {
const storage = context.systems.storage;
const viewport = context.viewport;

const multi = selectedIDs.length === 1 ? 'single' : 'multiple';
const entities = selectedIDs.map(entityID => graph.hasEntity(entityID)).filter(Boolean);
const isNew = entities.every(entity => entity.isNew());
const extent = utilTotalExtent(entities, graph);
Expand Down Expand Up @@ -74,8 +73,8 @@ export function operationRotate(context, selectedIDs) {
operation.tooltip = function() {
const disabledReason = operation.disabled();
return disabledReason ?
l10n.t(`operations.rotate.${disabledReason}.${multi}`) :
l10n.t(`operations.rotate.description.${multi}`);
l10n.t(`operations.rotate.${disabledReason}`, { n: selectedIDs.length }) :
l10n.t(`operations.rotate.description`, { n: selectedIDs.length });
};


Expand Down
5 changes: 2 additions & 3 deletions modules/operations/straighten.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function operationStraighten(context, selectedIDs) {
const wayIDs = ways.map(entity => entity.id);
const nodes = entities.filter(entity => entity.type === 'node');
const nodeIDs = nodes.map(entity => entity.id);
const multi = ((ways.length ? ways : nodes).length === 1 ? 'single' : 'multiple');

const coords = utilGetAllNodes(selectedIDs, graph).map(node => node.loc);
let extent = utilTotalExtent(selectedIDs, graph);
Expand Down Expand Up @@ -137,13 +136,13 @@ export function operationStraighten(context, selectedIDs) {
operation.tooltip = function() {
const disabledReason = operation.disabled();
return disabledReason ?
l10n.t(`operations.straighten.${disabledReason}.${multi}`) :
l10n.t(`operations.straighten.${disabledReason}`, { n: ways.length || nodes.length }) :
l10n.t(`operations.straighten.description.${geometry}` + (ways.length === 1 ? '' : 's'));
};


operation.annotation = function() {
return l10n.t(`operations.straighten.annotation.${geometry}`, { n: ways.length ? ways.length : nodes.length });
return l10n.t(`operations.straighten.annotation.${geometry}`, { n: ways.length || nodes.length });
};


Expand Down
20 changes: 12 additions & 8 deletions modules/validations/invalid_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ export function validationFormatting(context) {
message: function() {
const graph = editor.staging.graph;
const entity = graph.hasEntity(this.entityIds[0]);
return entity ? l10n.t('issues.invalid_format.website.message' + this.data,
{ feature: l10n.displayLabel(entity, graph), site: websites.join(', ') }) : '';
return entity ? l10n.t('issues.invalid_format.website.message', {
n: websites.length,
feature: l10n.displayLabel(entity, graph),
email: websites.join(', ')
}) : '';
},
reference: showReferenceWebsite,
entityIds: [entity.id],
hash: websites.join(),
data: (websites.length > 1) ? '_multi' : ''
hash: websites.join()
}));
}
}
Expand All @@ -86,13 +88,15 @@ export function validationFormatting(context) {
message: function() {
const graph = editor.staging.graph;
const entity = graph.hasEntity(this.entityIds[0]);
return entity ? l10n.t('issues.invalid_format.email.message' + this.data,
{ feature: l10n.displayLabel(entity, graph), email: emails.join(', ') }) : '';
return entity ? l10n.t('issues.invalid_format.email.message', {
n: emails.length,
feature: l10n.displayLabel(entity, graph),
email: emails.join(', ')
}) : '';
},
reference: showReferenceEmail,
entityIds: [entity.id],
hash: emails.join(),
data: (emails.length > 1) ? '_multi' : ''
hash: emails.join()
}));
}
}
Expand Down

0 comments on commit 41bbbcc

Please sign in to comment.