-
Notifications
You must be signed in to change notification settings - Fork 5.3k
feat: Make translation system key based and add annotation type to gutter icon aria labels #5524
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
Changes from all commits
295b340
c1c69e7
960feed
bc9d542
c37bd9d
66c99f4
3571497
ede6edc
21ca90e
7f43e04
66a88a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
var oop = require("./oop"); | ||
var EventEmitter = require("./event_emitter").EventEmitter; | ||
const reportError = require("./report_error").reportError; | ||
const defaultEnglishMessages = require("./default_english_messages").defaultEnglishMessages; | ||
|
||
var optionsProvider = { | ||
setOptions: function(optList) { | ||
|
@@ -61,8 +62,9 @@ var messages; | |
|
||
class AppConfig { | ||
constructor() { | ||
this.$defaultOptions = {}; | ||
} | ||
this.$defaultOptions = {}; | ||
messages = defaultEnglishMessages; | ||
} | ||
|
||
/** | ||
* @param {Object} obj | ||
|
@@ -142,14 +144,19 @@ class AppConfig { | |
} | ||
|
||
/** | ||
* @param {string} string | ||
* @param {string} key | ||
* @param {string} defaultString | ||
* @param {{ [x: string]: any; }} [params] | ||
*/ | ||
nls(string, params) { | ||
if (messages && !messages[string]) { | ||
warn("No message found for '" + string + "' in the provided messages, falling back to default English message."); | ||
} | ||
var translated = messages && messages[string] || string; | ||
nls(key, defaultString, params) { | ||
if (!messages[key]) { | ||
warn("No message found for the key '" + key + "' in the provided messages, trying to find a translation for the default string '" + defaultString + "'."); | ||
if (!messages[defaultString]) { | ||
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. are we keeping this default string logic for backwards compatibility reasons? 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. yeah, I kept this so that Ace users who currently have translations set-up don't get those broken by this change (well that's the goal at least 😄) |
||
warn("No message found for the default string '" + defaultString + "' in the provided messages. Falling back to the default English message."); | ||
} | ||
} | ||
|
||
var translated = messages[key] || messages[defaultString] || defaultString; | ||
if (params) { | ||
translated = translated.replace(/\$(\$|[\d]+)/g, function(_, name) { | ||
if (name == "$") return "$"; | ||
|
Uh oh!
There was an error while loading. Please reload this page.