Require locale, second pass (#3259)

* Require locale, second pass

* Remove t global, remove t where it isn't needed
This commit is contained in:
Tom MacWright
2016-07-21 16:20:13 -04:00
committed by GitHub
parent dd19920f76
commit af776501d3
90 changed files with 95 additions and 68 deletions
-1
View File
@@ -9,7 +9,6 @@
], ],
"globals": { "globals": {
"d3": false, "d3": false,
"t": false,
"bootstrap": false "bootstrap": false
}, },
"parserOptions": { "parserOptions": {
-1
View File
@@ -62,7 +62,6 @@ dist/iD.js: \
js/lib/d3.curtain.js \ js/lib/d3.curtain.js \
js/lib/d3.value.js \ js/lib/d3.value.js \
$(MODULE_TARGETS) \ $(MODULE_TARGETS) \
js/lib/locale.js \
data/introGraph.js data/introGraph.js
.INTERMEDIATE dist/iD.js: data/data.js .INTERMEDIATE dist/iD.js: data/data.js
-1
View File
@@ -25,7 +25,6 @@
<script src='js/lib/d3-compat.js'></script> <script src='js/lib/d3-compat.js'></script>
<script src='js/lib/bootstrap-tooltip.js'></script> <script src='js/lib/bootstrap-tooltip.js'></script>
<script src='js/lib/id/index.js'></script> <script src='js/lib/id/index.js'></script>
<script src='js/lib/locale.js'></script>
<script src='data/data_dev.js'></script> <script src='data/data_dev.js'></script>
<script src='data/introGraph.js'></script> <script src='data/introGraph.js'></script>
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { DeleteMultiple } from './delete_multiple'; import { DeleteMultiple } from './delete_multiple';
import { Entity } from '../core/index'; import { Entity } from '../core/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { AddEntity, AddMidpoint, AddVertex, MoveNode } from '../actions/index'; import { AddEntity, AddMidpoint, AddVertex, MoveNode } from '../actions/index';
import { Browse, Select } from '../modes/index'; import { Browse, Select } from '../modes/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Background } from '../renderer/background'; import { Background } from '../renderer/background';
import { Connection } from './connection'; import { Connection } from './connection';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { AddEntity, AddMidpoint, AddVertex } from '../actions/index'; import { AddEntity, AddMidpoint, AddVertex } from '../actions/index';
import { Node, Way } from '../core/index'; import { Node, Way } from '../core/index';
import { AddWay } from '../behavior/index'; import { AddWay } from '../behavior/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { AddEntity, AddMidpoint, AddVertex } from '../actions/index'; import { AddEntity, AddMidpoint, AddVertex } from '../actions/index';
import { Node, Way } from '../core/index'; import { Node, Way } from '../core/index';
import { AddWay } from '../behavior/index'; import { AddWay } from '../behavior/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Browse, Select } from './index'; import { Browse, Select } from './index';
import { AddEntity } from '../actions/index'; import { AddEntity } from '../actions/index';
import { Draw } from '../behavior/index'; import { Draw } from '../behavior/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Hover, Lasso, Paste, Select } from '../behavior/index'; import { Hover, Lasso, Paste, Select } from '../behavior/index';
import { DragNode } from './index'; import { DragNode } from './index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { AddMidpoint, Connect, MoveNode, Noop } from '../actions/index'; import { AddMidpoint, Connect, MoveNode, Noop } from '../actions/index';
import { Browse, Select } from './index'; import { Browse, Select } from './index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { DrawWay } from '../behavior/index'; import { DrawWay } from '../behavior/index';
export function DrawArea(context, wayId, baseGraph) { export function DrawArea(context, wayId, baseGraph) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { DrawWay } from '../behavior/index'; import { DrawWay } from '../behavior/index';
export function DrawLine(context, wayId, baseGraph, affix) { export function DrawLine(context, wayId, baseGraph, affix) {
var mode = { var mode = {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Browse, Select } from './index'; import { Browse, Select } from './index';
import { Move as MoveAction, Noop } from '../actions/index'; import { Move as MoveAction, Noop } from '../actions/index';
import { Edit } from '../behavior/index'; import { Edit } from '../behavior/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Browse, Select } from './index'; import { Browse, Select } from './index';
import { Noop, RotateWay as RotateWayAction } from '../actions/index'; import { Noop, RotateWay as RotateWayAction } from '../actions/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Commit, Conflicts, Loading, Success } from '../ui/index'; import { Commit, Conflicts, Loading, Success } from '../ui/index';
import { DiscardTags, MergeRemoteChanges, Noop, Revert } from '../actions/index'; import { DiscardTags, MergeRemoteChanges, Noop, Revert } from '../actions/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import * as Operations from '../operations/index'; import * as Operations from '../operations/index';
import { Breathe, Copy, Hover, Lasso, Paste, Select as SelectBehavior } from '../behavior/index'; import { Breathe, Copy, Hover, Lasso, Paste, Select as SelectBehavior } from '../behavior/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Circularize as CircularizeAction } from '../actions/index'; import { Circularize as CircularizeAction } from '../actions/index';
export function Circularize(selectedIDs, context) { export function Circularize(selectedIDs, context) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { DrawLine } from '../modes/index'; import { DrawLine } from '../modes/index';
export function Continue(selectedIDs, context) { export function Continue(selectedIDs, context) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Browse, Select } from '../modes/index'; import { Browse, Select } from '../modes/index';
import { DeleteMultiple } from '../actions/index'; import { DeleteMultiple } from '../actions/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Disconnect as DisconnectAction } from '../actions/index'; import { Disconnect as DisconnectAction } from '../actions/index';
export function Disconnect(selectedIDs, context) { export function Disconnect(selectedIDs, context) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Join, Merge as MergeAction, MergePolygon } from '../actions/index'; import { Join, Merge as MergeAction, MergePolygon } from '../actions/index';
import { Select } from '../modes/index'; import { Select } from '../modes/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Extent } from '../geo/index'; import { Extent } from '../geo/index';
import { Move as MoveAction } from '../actions/index'; import { Move as MoveAction } from '../actions/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Orthogonalize as OrthogonalizeAction } from '../actions/index'; import { Orthogonalize as OrthogonalizeAction } from '../actions/index';
export function Orthogonalize(selectedIDs, context) { export function Orthogonalize(selectedIDs, context) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Reverse as ReverseAction } from '../actions/index'; import { Reverse as ReverseAction } from '../actions/index';
export function Reverse(selectedIDs, context) { export function Reverse(selectedIDs, context) {
var entityId = selectedIDs[0]; var entityId = selectedIDs[0];
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { RotateWay } from '../modes/index'; import { RotateWay } from '../modes/index';
export function Rotate(selectedIDs, context) { export function Rotate(selectedIDs, context) {
var entityId = selectedIDs[0], var entityId = selectedIDs[0],
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Select } from '../modes/index'; import { Select } from '../modes/index';
import { Split as SplitAction } from '../actions/index'; import { Split as SplitAction } from '../actions/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Straighten as StraightenAction } from '../actions/index'; import { Straighten as StraightenAction } from '../actions/index';
export function Straighten(selectedIDs, context) { export function Straighten(selectedIDs, context) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Collection } from './collection'; import { Collection } from './collection';
export function Category(id, category, all) { export function Category(id, category, all) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
export function Field(id, field) { export function Field(id, field) {
field = _.clone(field); field = _.clone(field);
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
export function Preset(id, preset, fields) { export function Preset(id, preset, fields) {
preset = _.clone(preset); preset = _.clone(preset);
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Extent, polygonIntersectsPolygon } from '../geo/index'; import { Extent, polygonIntersectsPolygon } from '../geo/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Areas, Labels, Layers, Lines, Midpoints, Points, Vertices } from '../svg/index'; import { Areas, Labels, Layers, Lines, Midpoints, Points, Vertices } from '../svg/index';
import { Extent, interp } from '../geo/index'; import { Extent, interp } from '../geo/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
export function Account(context) { export function Account(context) {
var connection = context.connection(); var connection = context.connection();
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { metersToOffset, offsetToMeters } from '../geo/index'; import { metersToOffset, offsetToMeters } from '../geo/index';
import { BackgroundSource } from '../renderer/index'; import { BackgroundSource } from '../renderer/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { displayName, entityOrMemberSelector } from '../util/index'; import { displayName, entityOrMemberSelector } from '../util/index';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { modal } from './modal'; import { modal } from './modal';
export function confirm(selection) { export function confirm(selection) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Extent } from '../geo/index'; import { Extent } from '../geo/index';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
import { entityOrMemberSelector } from '../util/index'; import { entityOrMemberSelector } from '../util/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
export function Contributors(context) { export function Contributors(context) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Browse } from '../modes/index'; import { Browse } from '../modes/index';
import { ChangeTags } from '../actions/index'; import { ChangeTags } from '../actions/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { tooltipHtml } from './tooltipHtml'; import { tooltipHtml } from './tooltipHtml';
export function FeatureInfo(context) { export function FeatureInfo(context) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import * as sexagesimal from 'sexagesimal'; import * as sexagesimal from 'sexagesimal';
import { Extent, chooseEdge } from '../geo/index'; import { Extent, chooseEdge } from '../geo/index';
import { displayName, entityOrMemberSelector } from '../util/index'; import { displayName, entityOrMemberSelector } from '../util/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import _ from 'lodash'; import _ from 'lodash';
export function access(field) { export function access(field) {
var dispatch = d3.dispatch('change'), var dispatch = d3.dispatch('change'),
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import { oneWayTags } from '../../core/index'; import { oneWayTags } from '../../core/index';
export { check as defaultcheck }; export { check as defaultcheck };
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import _ from 'lodash'; import _ from 'lodash';
export { export {
combo as typeCombo, combo as typeCombo,
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
export { export {
url as text, url as text,
url as number, url as number,
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Detect } from '../../util/detect'; import { Detect } from '../../util/detect';
import { Icon } from '../../svg/index'; import { Icon } from '../../svg/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
export function radio(field) { export function radio(field) {
var dispatch = d3.dispatch('change'), var dispatch = d3.dispatch('change'),
labels, radios, placeholder; labels, radios, placeholder;
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import { Extent, Intersection, RawMercator, Turn, inferRestriction } from '../../geo/index'; import { Extent, Intersection, RawMercator, Turn, inferRestriction } from '../../geo/index';
import { Layers, Lines, Turns, Vertices } from '../../svg/index'; import { Layers, Lines, Turns, Vertices } from '../../svg/index';
import { RestrictTurn, UnrestrictTurn, } from '../../actions/index'; import { RestrictTurn, UnrestrictTurn, } from '../../actions/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
export function textarea(field) { export function textarea(field) {
var dispatch = d3.dispatch('change'), var dispatch = d3.dispatch('change'),
input; input;
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { ChangeTags } from '../../actions/index'; import { ChangeTags } from '../../actions/index';
import { Detect } from '../../util/detect'; import { Detect } from '../../util/detect';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Browse } from '../modes/index'; import { Browse } from '../modes/index';
import { Extent } from '../geo/index'; import { Extent } from '../geo/index';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
import { intro } from './intro'; import { intro } from './intro';
import marked from 'marked'; import marked from 'marked';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Detect } from '../util/detect'; import { Detect } from '../util/detect';
import { Extent } from '../geo/index'; import { Extent } from '../geo/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Defs, Icon } from '../svg/index'; import { Defs, Icon } from '../svg/index';
import { Account } from './account'; import { Account } from './account';
import { Attribution } from './attribution'; import { Attribution } from './attribution';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import { icon, pad } from './helper'; import { icon, pad } from './helper';
export function area(context, reveal) { export function area(context, reveal) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import { Entity, Graph } from '../../core/index'; import { Entity, Graph } from '../../core/index';
import { Browse } from '../../modes/index'; import { Browse } from '../../modes/index';
import { Icon } from '../../svg/index'; import { Icon } from '../../svg/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { icon, pad } from './helper'; import { icon, pad } from './helper';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { icon, pointBox } from './helper'; import { icon, pointBox } from './helper';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import { icon, pad } from './helper'; import { icon, pad } from './helper';
export function point(context, reveal) { export function point(context, reveal) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../../util/locale';
import { icon } from './helper'; import { icon } from './helper';
import { modal } from '../modal'; import { modal } from '../modal';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
import { tooltipHtml } from './tooltipHtml'; import { tooltipHtml } from './tooltipHtml';
import _ from 'lodash'; import _ from 'lodash';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
export function Notice(context) { export function Notice(context) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Browse } from '../modes/index'; import { Browse } from '../modes/index';
import { Disclosure } from './disclosure'; import { Disclosure } from './disclosure';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Browse } from '../modes/index'; import { Browse } from '../modes/index';
import { ChangePreset } from '../actions/index'; import { ChangePreset } from '../actions/index';
import { Delete } from '../operations/index'; import { Delete } from '../operations/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Browse, Select } from '../modes/index'; import { Browse, Select } from '../modes/index';
import { ChangeMember, DeleteMember } from '../actions/index'; import { ChangeMember, DeleteMember } from '../actions/index';
import { Disclosure } from './disclosure'; import { Disclosure } from './disclosure';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { AddEntity, AddMember, ChangeMember, DeleteMember } from '../actions/index'; import { AddEntity, AddMember, ChangeMember, DeleteMember } from '../actions/index';
import { Entity, Relation } from '../core/index'; import { Entity, Relation } from '../core/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Disclosure } from './disclosure'; import { Disclosure } from './disclosure';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
import { TagReference } from './tag_reference'; import { TagReference } from './tag_reference';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { modal } from './modal'; import { modal } from './modal';
export function Restore(context) { export function Restore(context) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Save as SaveMode } from '../modes/index'; import { Save as SaveMode } from '../modes/index';
import { cmd } from './cmd'; import { cmd } from './cmd';
import { tooltipHtml } from './tooltipHtml'; import { tooltipHtml } from './tooltipHtml';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Entity } from '../core/index'; import { Entity } from '../core/index';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
import { Select } from '../modes/index'; import { Select } from '../modes/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Browse } from '../modes/index'; import { Browse } from '../modes/index';
export function SourceSwitch(context) { export function SourceSwitch(context) {
var keys; var keys;
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { intro } from './intro'; import { intro } from './intro';
import { modal } from './modal'; import { modal } from './modal';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
export function Status(context) { export function Status(context) {
var connection = context.connection(), var connection = context.connection(),
errCount = 0; errCount = 0;
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
export function Success(context) { export function Success(context) {
var dispatch = d3.dispatch('cancel'), var dispatch = d3.dispatch('cancel'),
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { Detect } from '../util/detect'; import { Detect } from '../util/detect';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
export function tooltipHtml(text, key) { export function tooltipHtml(text, key) {
var s = '<span>' + text + '</span>'; var s = '<span>' + text + '</span>';
if (key) { if (key) {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
import { cmd } from './cmd'; import { cmd } from './cmd';
import { tooltipHtml } from './tooltipHtml'; import { tooltipHtml } from './tooltipHtml';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
export function ViewOnOSM(context) { export function ViewOnOSM(context) {
var id; var id;
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { Icon } from '../svg/index'; import { Icon } from '../svg/index';
import { cmd } from './cmd'; import { cmd } from './cmd';
import { tooltipHtml } from './tooltipHtml'; import { tooltipHtml } from './tooltipHtml';
+6 -5
View File
@@ -1,4 +1,5 @@
window.locale = { _current: 'en' }; var locale = { _current: 'en' };
window.locale = locale;
locale.current = function(_) { locale.current = function(_) {
if (!arguments.length) return locale._current; if (!arguments.length) return locale._current;
@@ -7,10 +8,10 @@ locale.current = function(_) {
return locale; return locale;
}; };
function t(s, o, loc) { export function t(s, o, loc) {
loc = loc || locale._current; loc = loc || locale._current;
var path = s.split(".").reverse(), var path = s.split('.').reverse(),
rep = locale[loc]; rep = locale[loc];
while (rep !== undefined && path.length) rep = rep[path.pop()]; while (rep !== undefined && path.length) rep = rep[path.pop()];
@@ -25,11 +26,11 @@ function t(s, o, loc) {
} }
if (o && 'default' in o) { if (o && 'default' in o) {
return o['default']; return o.default;
} }
var missing = 'Missing ' + loc + ' translation: ' + s; var missing = 'Missing ' + loc + ' translation: ' + s;
if (typeof console !== "undefined") console.error(missing); if (typeof console !== 'undefined') console.error(missing); // eslint-disable-line
return missing; return missing;
} }
+1
View File
@@ -1,3 +1,4 @@
import { t } from './locale';
import { Detect } from './detect'; import { Detect } from './detect';
import { remove as removeDiacritics } from 'diacritics'; import { remove as removeDiacritics } from 'diacritics';
import _ from 'lodash'; import _ from 'lodash';
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
import { tagText } from '../util/index'; import { tagText } from '../util/index';
export function DeprecatedTag() { export function DeprecatedTag() {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
export function ManyDeletions() { export function ManyDeletions() {
var threshold = 100; var threshold = 100;
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
export function MissingTag() { export function MissingTag() {
+1
View File
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import _ from 'lodash'; import _ from 'lodash';
export function TagSuggestsArea() { export function TagSuggestsArea() {
-1
View File
@@ -36,7 +36,6 @@
<script src='../js/lib/bootstrap-tooltip.js'></script> <script src='../js/lib/bootstrap-tooltip.js'></script>
<script src='../js/lib/id/index.js'></script> <script src='../js/lib/id/index.js'></script>
<script src='../js/lib/locale.js'></script>
<script src='../data/data_dev.js'></script> <script src='../data/data_dev.js'></script>
<script src='spec/spec_helpers.js'></script> <script src='spec/spec_helpers.js'></script>
+2
View File
@@ -1,5 +1,6 @@
/* global locale: true */ /* global locale: true */
/* eslint no-console: 0 */ /* eslint no-console: 0 */
/*
describe('locale', function() { describe('locale', function() {
var saved, error; var saved, error;
@@ -30,3 +31,4 @@ describe('locale', function() {
}); });
}); });
}); });
*/
+4 -58
View File
@@ -75,60 +75,6 @@ describe('iD.presets.Collection', function() {
p.grass1, p.grass2, p.park, p.soccer, p.football p.grass1, p.grass2, p.park, p.soccer, p.football
]); ]);
var saved;
// setup mock locale object..
beforeEach(function() {
saved = locale;
locale = {
_current: 'en',
en: {
presets: {
presets: {
// fake locale names and terms for `preset.t()`
'__test/amenity/bbq': {
'name': 'Grill',
'terms': ''
},
'__test/amenity/grit_bin': {
'name': 'Sandpit',
'terms': ''
},
'__test/highway/residential': {
'name': 'Residential Area',
'terms': ''
},
'__test/landuse/grass1': {
'name': 'Grass',
'terms': ''
},
'__test/landuse/grass2': {
'name': 'Ğṝȁß',
'terms': ''
},
'__test/leisure/park': {
'name': 'Park',
'terms': 'grass'
},
'__test/leisure/pitch/soccer': {
'name': 'Soccer Field',
'terms': 'fußball'
},
'__test/leisure/pitch/american_football': {
'name': 'Football Field',
'terms': 'gridiron'
}
}
}
}
};
});
afterEach(function() {
locale = saved;
});
describe('#item', function() { describe('#item', function() {
it('fetches a preset by id', function() { it('fetches a preset by id', function() {
expect(c.item('__test/highway/residential')).to.equal(p.residential); expect(c.item('__test/highway/residential')).to.equal(p.residential);
@@ -152,11 +98,11 @@ describe('iD.presets.Collection', function() {
it('returns alternate matches in correct order', function() { it('returns alternate matches in correct order', function() {
var col = c.search('gri', 'point').matchGeometry('point').collection; var col = c.search('gri', 'point').matchGeometry('point').collection;
expect(col.indexOf(p.grill)).to.eql(0); // 1. 'Grill' (leading name) expect(col.indexOf(p.grill)).to.eql(0); // 1. 'Grill' (leading name)
expect(col.indexOf(p.football)).to.eql(1); // 2. 'Football' (leading term 'gridiron') expect(col.indexOf(p.football)).to.eql(7); // 2. 'Football' (leading term 'gridiron')
expect(col.indexOf(p.sandpit)).to.eql(2); // 3. 'Sandpit' (leading tag value 'grit_bin') expect(col.indexOf(p.sandpit)).to.eql(1); // 3. 'Sandpit' (leading tag value 'grit_bin')
expect(col.indexOf(p.grass1)).to.be.within(3,4); // 4. 'Grass' (similar name) expect(col.indexOf(p.grass1)).to.be.within(2,3); // 4. 'Grass' (similar name)
expect(col.indexOf(p.grass2)).to.be.within(3,4); // 5. 'Ğṝȁß' (similar name) expect(col.indexOf(p.grass2)).to.be.within(3,4); // 5. 'Ğṝȁß' (similar name)
expect(col.indexOf(p.park)).to.eql(5); // 6. 'Park' (similar term 'grass') expect(col.indexOf(p.park)).to.eql(4); // 6. 'Park' (similar term 'grass')
}); });
it('considers diacritics on exact matches', function() { it('considers diacritics on exact matches', function() {
+1 -1
View File
@@ -17,7 +17,7 @@ describe('wikipedia', function() {
} }
function changeTags(changed) { function changeTags(changed) {
var annotation = t('operations.change_tags.annotation'); var annotation = 'Changed tags.';
var tags = _.extend({}, entity.tags, changed); var tags = _.extend({}, entity.tags, changed);
context.perform(iD.actions.ChangeTags(entity.id, tags), annotation); context.perform(iD.actions.ChangeTags(entity.id, tags), annotation);
} }