-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change translation on the fly #3764
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fb8efc2
Change translation on the fly
kepta a87227f
Merge branch 'master' into quick-translate
bhousel 1a5f155
Fix zoom behavior bind in map, delay removals to avoid flicker
bhousel d5805dc
import textDirection instead of caching first time rtl detection
bhousel 513382f
Only show splash and history restore prompts the first time
bhousel a004591
Remove test code, window.restart is now context.ui().restart
bhousel 2a39a25
Map div needs to remain ltr
bhousel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,13 @@ import { uiCmd } from './cmd'; | |
|
||
|
||
export function uiInit(context) { | ||
var uiInitCounter = 0; | ||
|
||
|
||
function render(container) { | ||
container | ||
.attr('dir', textDirection); | ||
|
||
var map = context.map(); | ||
|
||
var hash = behaviorHash(context); | ||
|
@@ -71,10 +76,6 @@ export function uiInit(context) { | |
.attr('dir', 'ltr') | ||
.call(map); | ||
|
||
if (textDirection === 'rtl') { | ||
d3.select('body').attr('dir', 'rtl'); | ||
} | ||
|
||
content | ||
.call(uiMapInMap(context)); | ||
|
||
|
@@ -228,6 +229,7 @@ export function uiInit(context) { | |
|
||
var mapDimensions = map.dimensions(); | ||
|
||
|
||
function onResize() { | ||
mapDimensions = utilGetDimensions(content, true); | ||
map.dimensions(mapDimensions); | ||
|
@@ -247,6 +249,7 @@ export function uiInit(context) { | |
}; | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra newline |
||
// pan amount | ||
var pa = 10; | ||
|
||
|
@@ -266,9 +269,11 @@ export function uiInit(context) { | |
|
||
context.enter(modeBrowse(context)); | ||
|
||
context.container() | ||
.call(uiSplash(context)) | ||
.call(uiRestore(context)); | ||
if (!uiInitCounter++) { | ||
context.container() | ||
.call(uiSplash(context)) | ||
.call(uiRestore(context)); | ||
} | ||
|
||
var authenticating = uiLoading(context) | ||
.message(t('loading_auth')) | ||
|
@@ -282,10 +287,15 @@ export function uiInit(context) { | |
.on('authDone.ui', function() { | ||
authenticating.close(); | ||
}); | ||
|
||
uiInitCounter++; | ||
} | ||
|
||
|
||
var renderCallback; | ||
|
||
function ui(node, callback) { | ||
renderCallback = callback; | ||
var container = d3.select(node); | ||
context.container(container); | ||
context.loadLocale(function(err) { | ||
|
@@ -298,6 +308,19 @@ export function uiInit(context) { | |
}); | ||
} | ||
|
||
|
||
ui.restart = function(arg) { | ||
context.locale(arg); | ||
context.loadLocale(function(err) { | ||
if (!err) { | ||
context.container().selectAll('*').remove(); | ||
render(context.container()); | ||
if (renderCallback) renderCallback(); | ||
} | ||
}); | ||
}; | ||
|
||
|
||
ui.sidebar = uiSidebar(context); | ||
|
||
return ui; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, I've been adding 2 spaces before function blocks and anywhere else I want documentation to go.