FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #2704 from federicobond/language-helpers · dimr/processing@3ab305f · GitHub

Repository navigation

Commit 3ab305f

Browse files
committed
Merge pull request processing#2704 from federicobond/language-helpers
Add some helper methods to Language
2 parents d635c9e + 44f340b commit 3ab305f

6 files changed

Lines changed: 27 additions & 20 deletions

File tree

‎app/src/processing/app/Editor.java‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -364,15 +364,8 @@ public boolean importData(TransferHandler.TransferSupport support) {
364364
return false;
365365
}
366366

367-
if (successful == 0) {
368-
statusError(Language.text("editor.status.drag_and_drop.no_files_added"));
367+
statusNotice(Language.pluralize("editor.status.drag_and_drop.files_added", successful));
369368

370-
} else if (successful == 1) {
371-
statusNotice(Language.text("editor.status.drag_and_drop.one_file_added"));
372-
373-
} else {
374-
statusNotice(String.format(Language.text("editor.status.drag_and_drop.n_files_added"), successful));
375-
}
376369
return true;
377370
}
378371
}
@@ -2111,7 +2104,7 @@ protected void handleFindReference() {
21112104
if (text.length() == 0) {
21122105
statusNotice(Language.text("editor.status.find_reference.select_word_first"));
21132106
} else {
2114-
statusNotice(String.format(Language.text("editor.status.find_reference.not_available"), text));
2107+
statusNotice(Language.interpolate("editor.status.find_reference.not_available", text));
21152108
}
21162109
}
21172110
}

‎app/src/processing/app/Language.java‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ static public String text(String text) {
161161
return init().bundle.getString(text);
162162
}
163163

164+
static public String interpolate(String text, Object... arguments) {
165+
return String.format(init().bundle.getString(text), arguments);
166+
}
167+
168+
static public String pluralize(String text, int count) {
169+
ResourceBundle bundle = init().bundle;
170+
171+
String fmt = text + ".%s";
172+
173+
if (bundle.containsKey(String.format(fmt, count))) {
174+
return interpolate(String.format(fmt, count), count);
175+
}
176+
return interpolate(String.format(fmt, "n"), count);
177+
}
164178

165179
/** Get all available languages */
166180
static public Map<String, String> getLanguages() {
@@ -221,4 +235,4 @@ public ResourceBundle newBundle(String baseName, Locale locale, String format, C
221235
return bundle;
222236
}
223237
}
224-
}
238+
}

‎app/src/processing/app/contrib/ContributionPanel.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ else if (version.toLowerCase().startsWith("v")) // For ketai library
675675

676676
private void installContribution(AvailableContribution info) {
677677
if (info.link == null) {
678-
listPanel.contribManager.status.setErrorMessage(String.format(Language.text("contributions.unsupported_operating_system"), info.getType()));
678+
listPanel.contribManager.status.setErrorMessage(Language.interpolate("contributions.unsupported_operating_system", info.getType()));
679679
} else {
680680
installContribution(info, info.link);
681681
}

‎app/src/processing/app/languages/PDE.properties‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ editor.status.autoformat.no_changes = No changes necessary for Auto Format.
222222
editor.status.autoformat.finished = Auto Format finished.
223223
editor.status.find_reference.select_word_first = First select a word to find in the reference.
224224
editor.status.find_reference.not_available = No reference available for "%s".
225-
editor.status.drag_and_drop.no_files_added = No files were added to the sketch.
226-
editor.status.drag_and_drop.one_file_added = One file added to the sketch.
227-
editor.status.drag_and_drop.n_files_added = %d files added to the sketch.
225+
editor.status.drag_and_drop.files_added.0 = No files were added to the sketch.
226+
editor.status.drag_and_drop.files_added.1 = One file added to the sketch.
227+
editor.status.drag_and_drop.files_added.n = %d files added to the sketch.
228228
editor.status.saving = Saving...
229229
editor.status.saving.done = Done saving.
230230
editor.status.saving.canceled = Save canceled.

‎app/src/processing/app/languages/PDE_el.properties‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ editor.status.autoformat.no_changes = Δεν χρειάζονται αλλαγέ
217217
editor.status.autoformat.finished = Ολοκληρώθηκε η Αυτόματη μορφοποίηση.
218218
editor.status.find_reference.select_word_first = Επιλέξτε πρώτα μια λέξη προς αναζήτηση στην Processing Reference.
219219
editor.status.find_reference.not_available = Δεν υπάρχει καταχώρηση για το "%s" στην Processing Reference.
220-
editor.status.drag_and_drop.no_files_added = Δεν προστέθηκαν αρχεία στο Σχέδιο.
221-
editor.status.drag_and_drop.one_file_added = Ένα αρχείο προστέθηκε στο Σχέδιο.
222-
editor.status.drag_and_drop.n_files_added = %d files αρχεία προστέθηκαν στο Σχέδιο.
220+
editor.status.drag_and_drop.files_added.0 = Δεν προστέθηκαν αρχεία στο Σχέδιο.
221+
editor.status.drag_and_drop.files_added.1 = Ένα αρχείο προστέθηκε στο Σχέδιο.
222+
editor.status.drag_and_drop.files_added.n = %d files αρχεία προστέθηκαν στο Σχέδιο.
223223
editor.status.saving = Αποθήκευση...
224224
editor.status.saving.done = Ολοκλήρωση αποθήκευσης.
225225
editor.status.saving.canceled = Ακύρωση αποθήκευσης.

‎app/src/processing/app/languages/PDE_pt.properties‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ editor.status.autoformat.no_changes = Não foram necessárias alterações para
217217
editor.status.autoformat.finished = Auto Formatação completa.
218218
editor.status.find_reference.select_word_first = Primeiro escolha uma palavra para procurar na referência.
219219
editor.status.find_reference.not_available = Não existe refrência disponivel para "%s".
220-
editor.status.drag_and_drop.no_files_added = Nenhuns ficheiros foram adicionados ao sketch.
221-
editor.status.drag_and_drop.one_file_added = Um ficheiro adicionado ao sketch.
222-
editor.status.drag_and_drop.n_files_added = %d ficheiros adicionados ao sketch.
220+
editor.status.drag_and_drop.files_added.0 = Nenhuns ficheiros foram adicionados ao sketch.
221+
editor.status.drag_and_drop.files_added.1 = Um ficheiro adicionado ao sketch.
222+
editor.status.drag_and_drop.files_added.n = %d ficheiros adicionados ao sketch.
223223
editor.status.saving = A Guardar...
224224
editor.status.saving.done = Guardado com sucesso.
225225
editor.status.saving.canceled = Guardar cancelado.

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL