Translate all alerts to the en.ini file (#124)

This commit is contained in:
David Capello 2017-10-17 18:00:45 -03:00
parent 36a44e6691
commit a9b183729f
30 changed files with 320 additions and 181 deletions

View File

@ -6,6 +6,137 @@ title = Warning - Important
description = You are going to enter in "Advanced Mode".
dont_show_again = Don't show this again
[alerts]
applying_filter = FX<<Applying effect...||&Cancel
auto_remap = <<<END
Automatic Remap
<<The remap operation cannot be perfectly done for more than 256 colors.
<<Do you want to continue anyway?
||&OK||&Cancel"
END
cannot_delete_all_layers = Error<<You cannot delete all layers.||&OK
cannot_file_overwrite_on_export = <<<END
Overwrite Warning
<<You cannot Export with the same name (overwrite the original file).
<<Use File > Save As menu option in that case.
||&OK
END
cannot_open_file = Problem<<Cannot open file:<<{0}||&OK
cannot_open_folder = Problem<<Cannot open folder:<<{0}||&OK
cannot_save_in_read_only_file = Problem<<The selected file is read-only. Try with other file.||&Go back
clipboard_access_locked = Error<<Cannot access to the clipboard.<<Maybe other application is using it.||&OK
clipboard_image_format_not_supported = Error<<The current clipboard image format is not supported.||&OK
delete_selected_backups = <<<END
Warning
<<Do you really want to delete the selected {0} backup(s)?
||&Yes||&No
END
delete_shortcut = <<<END
Warning
<<Do you really want to delete '{0}' keyboard shortcut?
||&Yes||&No
END
empty_rect_importing_sprite_sheet = <<<END
Import Sprite Sheet
<<The specified rectangle does not create any tile.
<<Select a rectangle inside the sprite region.
||&OK
END
error_loading_file = Error<<Error loading file: {0}||&OK
error_saving_file = Error<<Error saving file: {0}||&OK
export_animation_in_sequence = <<<END
Notice
<<Do you want to export the animation in {0} files?
<<{1}, {2}...
||&Agree||&Cancel
END
file_format_doesnt_support_error = <<<END
Error
<<File format ".{0}" doesn't support:
{1}
<<You must select other format.
<<Use ".ase" to keep all the sprite information.
||&OK
END
file_format_doesnt_support_warning = <<<END
Warning
<<File format ".{0}" doesn't support:
{1}
<<You can use ".ase" format to keep all this information.
<<Do you want continue with ".{0}" anyway?
||&Yes||&No
END
file_format_alpha_channel = Alpha channel
file_format_frame_tags = Frame tags
file_format_frames = Frames
file_format_grayscale_mode = Grayscale mode
file_format_indexed_mode = Indexed mode
file_format_layers = Layers
file_format_palette_changes = Palette changes between frames
file_format_rgb_mode = RGB mode
invalid_chars_in_filename = <<<END
Error
<<The file name cannot contain the following character(s):
<< {0}
||&OK
END
invalid_fg_or_bg_colors = <<<END
Aseprite
<<The current selected foreground and/or background color
<<is out of range. Select a valid color in the palette.
||&OK
END
job_working = {0}<<Working...||&Cancel
nothing_to_report = Crash Report<<Nothing to report||&OK
uninstall_extension_warning = <<<END
Warning
<<Do you really want to uninstall '{0}' extension?
||&Yes||&No
END
update_screen_ui_scaling_with_theme_values = <<<END
Update Screen/UI Scaling
<<The new theme '{0}' wants to adjust some values for you:
<< Screen Scaling: {1}% -> {2}%
<< UI Scaling: {3}% -> {4}%
<<Allow these changes?
||&Adjust Scaling||&Don't Adjust Scaling
END
update_extension = <<<END
Update Extension
<<The extension '{0}' already exists.
<<Do you want to {1} from v{2} to v{3}?
||&Yes||&No
END
update_extension_downgrade = downgrade
update_extension_upgrade = upgrade
restart_by_preferences = <<<END
Aseprite
<<You must restart the program to see your changes to:{0}
||&OK
END
restart_by_preferences_save_recovery_data_period = Automatically save recovery data every X minutes
restore_all_shortcuts = <<<END
Warning
<<Do you want to restore all keyboard shortcuts
<<to their original default settings?
||&Yes||&No
END
save_sprite_changes = <<<END
Warning
<<Saving changes to the sprite
<<"{0}" before {1}?
||&Save||Do&n't Save||&Cancel
END
save_sprite_changes_quitting = quitting
save_sprite_changes_closing = closing
overwrite_existent_file = Warning<<File exists, overwrite it?<<{0}||&Yes||&No||&Cancel
overwrite_files_on_export_sprite_sheet = <<<END
Export Sprite Sheet Warning
<<Do you want to overwrite the following file(s)?
{0}
||&Yes||&No
END
[brush_slot_params]
brush = Brush:
brush_type = Type

View File

@ -16,6 +16,7 @@
#include "app/document_exporter.h"
#include "app/file/file.h"
#include "app/file_selector.h"
#include "app/i18n/strings.h"
#include "app/modules/editors.h"
#include "app/pref/preferences.h"
#include "app/restore_visible_layers.h"
@ -29,6 +30,7 @@
#include "base/string.h"
#include "doc/frame_tag.h"
#include "doc/layer.h"
#include "fmt/format.h"
#include "export_sprite_sheet.xml.h"
@ -138,7 +140,6 @@ namespace {
!dataname.empty() &&
base::is_file(dataname))) {
std::stringstream text;
text << "Export Sprite Sheet Warning<<Do you want to overwrite the following file(s)?";
if (base::is_file(filename))
text << "<<" << base::get_file_name(filename).c_str();
@ -146,8 +147,9 @@ namespace {
if (base::is_file(dataname))
text << "<<" << base::get_file_name(dataname).c_str();
text << "||&Yes||&No";
if (Alert::show(text.str().c_str()) != 1)
if (ui::Alert::show(
fmt::format(Strings::alerts_overwrite_files_on_export_sprite_sheet(),
text.str())) != 1)
return false;
}
return true;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -16,6 +16,7 @@
#include "app/context_access.h"
#include "app/document_access.h"
#include "app/document_api.h"
#include "app/i18n/strings.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
@ -379,10 +380,7 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
}
if (animation.size() == 0) {
Alert::show("Import Sprite Sheet"
"<<The specified rectangle does not create any tile."
"<<Select a rectangle inside the sprite region."
"||&OK");
Alert::show(Strings::alerts_empty_rect_importing_sprite_sheet());
return;
}

View File

@ -13,6 +13,7 @@
#include "app/commands/command.h"
#include "app/context.h"
#include "app/file_selector.h"
#include "app/i18n/strings.h"
#include "app/match_words.h"
#include "app/resource_finder.h"
#include "app/tools/tool.h"
@ -28,6 +29,7 @@
#include "base/scoped_value.h"
#include "base/split_string.h"
#include "base/string.h"
#include "fmt/format.h"
#include "ui/graphics.h"
#include "ui/listitem.h"
#include "ui/paint_event.h"
@ -144,11 +146,10 @@ private:
// Key::disableAccel() will modify the accels() collection itself.
ui::Accelerator accel = m_key->accels()[index];
if (Alert::show(
"Warning"
"<<Do you really want to delete '%s' keyboard shortcut?"
"||&Yes||&No",
accel.toString().c_str()) != 1)
if (ui::Alert::show(
fmt::format(
Strings::alerts_delete_shortcut(),
accel.toString())) != 1)
return;
m_key->disableAccel(accel);
@ -586,10 +587,7 @@ private:
}
void onReset() {
if (Alert::show("Warning"
"<<Do you want to restore all keyboard shortcuts"
"<<to their original default settings?"
"||&Yes||&No") == 1) {
if (ui::Alert::show(Strings::alerts_restore_all_shortcuts()) == 1) {
app::KeyboardShortcuts::instance()->reset();
layout();
}

View File

@ -13,11 +13,13 @@
#include "app/commands/params.h"
#include "app/context_access.h"
#include "app/file_selector.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/util/msk_file.h"
#include "doc/mask.h"
#include "doc/sprite.h"
#include "fmt/format.h"
#include "ui/alert.h"
namespace app {
@ -68,9 +70,10 @@ void LoadMaskCommand::onExecute(Context* context)
}
base::UniquePtr<Mask> mask(load_msk_file(m_filename.c_str()));
if (!mask)
throw base::Exception("Error loading .msk file: %s",
static_cast<const char*>(m_filename.c_str()));
if (!mask) {
ui::Alert::show(fmt::format(Strings::alerts_error_loading_file(), m_filename));
return;
}
{
ContextWriter writer(reader);

View File

@ -14,10 +14,12 @@
#include "app/context.h"
#include "app/file/palette_file.h"
#include "app/file_selector.h"
#include "app/i18n/strings.h"
#include "app/modules/palettes.h"
#include "base/fs.h"
#include "base/unique_ptr.h"
#include "doc/palette.h"
#include "fmt/format.h"
#include "ui/alert.h"
namespace app {
@ -80,7 +82,7 @@ void LoadPaletteCommand::onExecute(Context* context)
base::UniquePtr<doc::Palette> palette(load_palette(filename.c_str()));
if (!palette) {
if (context->isUIAvailable())
Alert::show("Error<<Loading palette file||&Close");
ui::Alert::show(fmt::format(Strings::alerts_error_loading_file(), filename));
return;
}

View File

@ -14,6 +14,7 @@
#include "app/context.h"
#include "app/extensions.h"
#include "app/file_selector.h"
#include "app/i18n/strings.h"
#include "app/ini_file.h"
#include "app/launcher.h"
#include "app/pref/preferences.h"
@ -28,6 +29,7 @@
#include "base/string.h"
#include "base/version.h"
#include "doc/image.h"
#include "fmt/format.h"
#include "render/render.h"
#include "she/display.h"
#include "she/system.h"
@ -371,7 +373,7 @@ public:
m_pref.general.dataRecovery(enableDataRecovery()->isSelected());
m_pref.general.dataRecoveryPeriod(newPeriod);
warnings += "<<- Automatically save recovery data every";
warnings += "<<- " + Strings::alerts_restart_by_preferences_save_recovery_data_period();
}
m_pref.editor.zoomFromCenterWithWheel(zoomFromCenterWithWheel()->isSelected());
@ -463,9 +465,9 @@ public:
m_pref.save();
if (!warnings.empty()) {
ui::Alert::show(PACKAGE
"<<You must restart the program to see your changes to:%s"
"||&OK", warnings.c_str());
ui::Alert::show(
fmt::format(Strings::alerts_restart_by_preferences(),
warnings));
}
if (reset_screen)
@ -778,17 +780,13 @@ private:
// Ask if the user want to adjust the Screen/UI Scaling
const int result =
ui::Alert::show(
"Update Screen/UI Scaling"
"<<The new theme '%s' wants to adjust some values for you:"
"<< Screen Scaling: %d%% -> %d%%"
"<< UI Scaling: %d%% -> %d%%"
"<<Allow these changes?"
"||&Adjust Scaling||&Don't Adjust Scaling",
themeName.c_str(),
100 * m_pref.general.screenScale(),
100 * (newScreenScale > 0 ? newScreenScale: m_pref.general.screenScale()),
100 * m_pref.general.uiScale(),
100 * (newUIScale > 0 ? newUIScale: m_pref.general.uiScale()));
fmt::format(
Strings::alerts_update_screen_ui_scaling_with_theme_values(),
themeName,
100 * m_pref.general.screenScale(),
100 * (newScreenScale > 0 ? newScreenScale: m_pref.general.screenScale()),
100 * m_pref.general.uiScale(),
100 * (newUIScale > 0 ? newUIScale: m_pref.general.uiScale())));
if (result == 1) {
// Preferred UI Scaling factor
@ -865,14 +863,13 @@ private:
// Uninstall?
if (ui::Alert::show(
"Update Extension"
"<<The extension '%s' already exists."
"<<Do you want to %s from v%s to v%s?"
"||&Yes||&No",
ext->name().c_str(),
(isDowngrade ? "downgrade": "upgrade"),
ext->version().c_str(),
info.version.c_str()) != 1)
fmt::format(
Strings::alerts_update_extension(),
ext->name(),
(isDowngrade ? Strings::alerts_update_extension_downgrade():
Strings::alerts_update_extension_upgrade()),
ext->version(),
info.version)) != 1)
return;
// Uninstall old version
@ -917,10 +914,9 @@ private:
return;
if (ui::Alert::show(
"Warning"
"<<Do you really want to uninstall '%s' extension?"
"||&Yes||&No",
item->text().c_str()) != 1)
fmt::format(
Strings::alerts_uninstall_extension_warning(),
item->text())) != 1)
return;
try {

View File

@ -195,9 +195,7 @@ void PasteTextCommand::onExecute(Context* ctx)
}
}
catch (const std::exception& ex) {
ui::Alert::show(PACKAGE
"<<%s"
"||&OK", ex.what());
Console::showException(ex);
}
}

View File

@ -12,9 +12,10 @@
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/document_api.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/ui/status_bar.h"
#include "app/transaction.h"
#include "app/ui/status_bar.h"
#include "doc/layer.h"
#include "doc/sprite.h"
#include "ui/alert.h"
@ -69,7 +70,7 @@ void RemoveLayerCommand::onExecute(Context* context)
}
if (deletedTopLevelLayers == sprite->root()->layersCount()) {
ui::Alert::show("Error<<You cannot delete all layers.||&OK");
ui::Alert::show(Strings::alerts_cannot_delete_all_layers());
return;
}
@ -79,7 +80,7 @@ void RemoveLayerCommand::onExecute(Context* context)
}
else {
if (sprite->allLayersCount() == 1) {
ui::Alert::show("Error<<You cannot delete the last layer.||&OK");
ui::Alert::show(Strings::alerts_cannot_delete_all_layers());
return;
}

View File

@ -18,6 +18,7 @@
#include "app/context_access.h"
#include "app/file/file.h"
#include "app/file_selector.h"
#include "app/i18n/strings.h"
#include "app/job.h"
#include "app/modules/gui.h"
#include "app/pref/preferences.h"
@ -207,10 +208,7 @@ bool SaveFileBaseCommand::saveAsDialog(
if (!forbiddenFilename.empty() &&
base::normalize_path(forbiddenFilename) ==
base::normalize_path(filename)) {
ui::Alert::show("Overwrite Warning"
"<<You cannot save a copy with the same name (overwrite the original file)."
"<<Use File > Save menu option in that case."
"||&OK");
ui::Alert::show(Strings::alerts_cannot_file_overwrite_on_export());
goto again;
}

View File

@ -11,10 +11,12 @@
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/file_selector.h"
#include "app/i18n/strings.h"
#include "app/util/msk_file.h"
#include "base/fs.h"
#include "doc/mask.h"
#include "doc/sprite.h"
#include "fmt/format.h"
#include "ui/alert.h"
namespace app {
@ -55,7 +57,7 @@ void SaveMaskCommand::onExecute(Context* context)
std::string filename = selFilename.front();
if (save_msk_file(document->mask(), filename.c_str()) != 0)
ui::Alert::show("Error<<Error saving .msk file<<%s||&Close", filename.c_str());
ui::Alert::show(fmt::format(Strings::alerts_error_saving_file(), filename));
}
Command* CommandFactory::createSaveMaskCommand()

View File

@ -14,9 +14,11 @@
#include "app/context.h"
#include "app/file/palette_file.h"
#include "app/file_selector.h"
#include "app/i18n/strings.h"
#include "app/modules/palettes.h"
#include "base/fs.h"
#include "doc/palette.h"
#include "fmt/format.h"
#include "ui/alert.h"
namespace app {
@ -68,7 +70,7 @@ void SavePaletteCommand::onExecute(Context* context)
}
if (!save_palette(filename.c_str(), palette, 16)) // TODO 16 should be configurable
Alert::show("Error<<Saving palette file||&Close");
ui::Alert::show(fmt::format(Strings::alerts_error_saving_file(), filename));
if (m_preset == get_default_palette_preset_name()) {
set_default_palette(palette);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -11,6 +11,7 @@
#include "app/app.h"
#include "app/commands/filters/filter_manager_impl.h"
#include "app/console.h"
#include "app/i18n/strings.h"
#include "app/ini_file.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
@ -77,8 +78,7 @@ FilterWorker::FilterWorker(FilterManagerImpl* filterMgr)
m_cancelled = false;
m_abort = false;
m_alertWindow = ui::Alert::create(PACKAGE
"<<Applying effect...||&Cancel");
m_alertWindow = ui::Alert::create(Strings::alerts_applying_filter());
m_alertWindow->addProgress();
m_timer.Tick.connect(&FilterWorker::onMonitoringTick, this);

View File

@ -20,6 +20,7 @@
#include "base/fs.h"
#include "doc/doc.h"
#include "fixmath/fixmath.h"
#include "fmt/format.h"
#include "ui/alert.h"
#include "zlib.h"
@ -403,14 +404,17 @@ bool AseFormat::onPostLoad(FileOp* fop)
if (flat && ase_has_groups(group)) {
if (fop->context() &&
fop->context()->isUIAvailable() &&
ui::Alert::show("Warning"
"<<The selected file \"%s\" has layer groups."
"<<Do you want to open it with \"%s %s\" anyway?"
"<<"
"<<Note: Layers inside groups will be converted to top level layers."
"||&Yes||&No",
base::get_file_name(fop->filename()).c_str(),
PACKAGE, ver.c_str()) != 1) {
ui::Alert::show(
fmt::format(
// This message is not translated because is used only in the old v1.1 only
"Warning"
"<<The selected file \"{0}\" has layer groups."
"<<Do you want to open it with \"{1} {2}\" anyway?"
"<<"
"<<Note: Layers inside groups will be converted to top level layers."
"||&Yes||&No",
base::get_file_name(fop->filename()),
PACKAGE, ver)) != 1) {
return false;
}
ase_ungroup_all(group);

View File

@ -19,6 +19,7 @@
#include "app/file/format_options.h"
#include "app/file/split_filename.h"
#include "app/filename_formatter.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
#include "app/ui/status_bar.h"
@ -29,6 +30,7 @@
#include "base/string.h"
#include "dio/detect_format.h"
#include "doc/doc.h"
#include "fmt/format.h"
#include "render/quantization.h"
#include "render/render.h"
#include "ui/alert.h"
@ -327,6 +329,13 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
// Get the extension of the filename (in lower case)
LOG("FILE: Saving document \"%s\"\n", filename.c_str());
// Check for read-only attribute
if (base::has_readonly_attr(filename)) {
fop->setError("Error saving \"%s\" file, it's read-only",
filename.c_str());
return fop.release();
}
// Get the format through the extension of the filename
fop->m_format = FileFormatsManager::instance()->getFileFormat(
dio::detect_format_by_file_extension(filename));
@ -347,32 +356,32 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
case IMAGE_RGB:
if (!(fop->m_format->support(FILE_SUPPORT_RGB))) {
warnings += "<<- RGB format";
warnings += "<<- " + Strings::alerts_file_format_rgb_mode();
fatal = true;
}
if (!(fop->m_format->support(FILE_SUPPORT_RGBA)) &&
fop->m_document->sprite()->needAlpha()) {
warnings += "<<- Alpha channel";
warnings += "<<- " + Strings::alerts_file_format_alpha_channel();
}
break;
case IMAGE_GRAYSCALE:
if (!(fop->m_format->support(FILE_SUPPORT_GRAY))) {
warnings += "<<- Grayscale format";
warnings += "<<- " + Strings::alerts_file_format_grayscale_mode();
fatal = true;
}
if (!(fop->m_format->support(FILE_SUPPORT_GRAYA)) &&
fop->m_document->sprite()->needAlpha()) {
warnings += "<<- Alpha channel";
warnings += "<<- " + Strings::alerts_file_format_alpha_channel();
}
break;
case IMAGE_INDEXED:
if (!(fop->m_format->support(FILE_SUPPORT_INDEXED))) {
warnings += "<<- Indexed format";
warnings += "<<- " + Strings::alerts_file_format_indexed_mode();
fatal = true;
}
break;
@ -382,14 +391,14 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
if (fop->m_roi.frames() > 1) {
if (!fop->m_format->support(FILE_SUPPORT_FRAMES) &&
!fop->m_format->support(FILE_SUPPORT_SEQUENCES)) {
warnings += "<<- Frames";
warnings += "<<- " + Strings::alerts_file_format_frames();
}
}
// Layers support
if (fop->m_document->sprite()->root()->layersCount() > 1) {
if (!(fop->m_format->support(FILE_SUPPORT_LAYERS))) {
warnings += "<<- Layers";
warnings += "<<- " + Strings::alerts_file_format_layers();
}
}
@ -397,14 +406,14 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
if (fop->m_document->sprite()->getPalettes().size() > 1) {
if (!fop->m_format->support(FILE_SUPPORT_PALETTES) &&
!fop->m_format->support(FILE_SUPPORT_SEQUENCES)) {
warnings += "<<- Palette changes between frames";
warnings += "<<- " + Strings::alerts_file_format_palette_changes();
}
}
// Check frames support
if (!fop->m_document->sprite()->frameTags().empty()) {
if (!fop->m_format->support(FILE_SUPPORT_FRAME_TAGS)) {
warnings += "<<- Frame tags";
warnings += "<<- " + Strings::alerts_file_format_frame_tags();
}
}
@ -438,26 +447,12 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
if (!warnings.empty()) {
// Interative
if (context && context->isUIAvailable()) {
warnings += "<<You can use \".ase\" format to keep all this information.";
std::string title, buttons;
if (fatal) {
title = "Error";
buttons = "&Close";
}
else {
title = "Warning";
buttons = "&Yes||&No";
}
int ret = ui::Alert::show("%s<<File format \".%s\" doesn't support:%s"
"<<Do you want continue with \".%s\" anyway?"
"||%s",
title.c_str(),
fop->m_format->name(),
warnings.c_str(),
fop->m_format->name(),
buttons.c_str());
int ret = ui::Alert::show(
fmt::format(
(fatal ? Strings::alerts_file_format_doesnt_support_error():
Strings::alerts_file_format_doesnt_support_warning()),
fop->m_format->name(),
warnings));
// Operation can't be done (by fatal error) or the user cancel
// the operation
@ -510,13 +505,12 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
if (context && context->isUIAvailable() &&
fop->m_seq.filename_list.size() > 1 &&
ui::Alert::show("Notice"
"<<Do you want to export the animation in %d files?"
"<<%s, %s..."
"||&Agree||&Cancel",
int(fop->m_seq.filename_list.size()),
base::get_file_name(fop->m_seq.filename_list[0]).c_str(),
base::get_file_name(fop->m_seq.filename_list[1]).c_str()) != 1) {
ui::Alert::show(
fmt::format(
Strings::alerts_export_animation_in_sequence(),
int(fop->m_seq.filename_list.size()),
base::get_file_name(fop->m_seq.filename_list[0]),
base::get_file_name(fop->m_seq.filename_list[1]))) != 1) {
return nullptr;
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2016 David Capello
// Copyright (C) 2016, 2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -61,7 +61,7 @@ Strings::Strings()
}
}
const std::string& Strings::translate(const char* id)
const std::string& Strings::translate(const char* id) const
{
auto it = m_strings.find(id);
if (it != m_strings.end())

View File

@ -16,17 +16,17 @@
namespace app {
// Singleton class to load and access "strings/english.txt" file.
class Strings {
// Singleton class to load and access "strings/en.ini" file.
class Strings : public app::gen::Strings<app::Strings> {
public:
static Strings* instance();
const std::string& translate(const char* id);
const std::string& translate(const char* id) const;
private:
Strings();
std::unordered_map<std::string, std::string> m_strings;
mutable std::unordered_map<std::string, std::string> m_strings;
};
} // namespace app

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -12,9 +12,11 @@
#include "app/app.h"
#include "app/console.h"
#include "app/i18n/strings.h"
#include "base/mutex.h"
#include "base/scoped_lock.h"
#include "base/thread.h"
#include "fmt/format.h"
#include "ui/alert.h"
#include "ui/widget.h"
#include "ui/window.h"
@ -43,7 +45,8 @@ Job::Job(const char* jobName)
m_mutex = new base::mutex();
if (App::instance()->isGui()) {
m_alert_window = ui::Alert::create("%s<<Working...||&Cancel", jobName);
m_alert_window = ui::Alert::create(
fmt::format(Strings::alerts_job_working(), jobName));
m_alert_window->addProgress();
m_timer.reset(new ui::Timer(kMonitoringPeriod, m_alert_window.get()));

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2015, 2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -10,8 +10,10 @@
#include "app/launcher.h"
#include "app/i18n/strings.h"
#include "base/exception.h"
#include "base/launcher.h"
#include "fmt/format.h"
#include "ui/alert.h"
namespace app {
@ -25,13 +27,13 @@ void open_url(const std::string& url)
void open_file(const std::string& file)
{
if (!base::launcher::open_file(file))
ui::Alert::show("Problem<<Cannot open file:<<%s||&Close", file.c_str());
ui::Alert::show(fmt::format(Strings::alerts_cannot_open_file(), file));
}
void open_folder(const std::string& file)
{
if (!base::launcher::open_folder(file))
ui::Alert::show("Problem<<Cannot open folder:<<%s||&Close", file.c_str());
ui::Alert::show(fmt::format(Strings::alerts_cannot_open_folder(), file));
}
} // namespace launcher

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -11,6 +11,8 @@
#include "app/send_crash.h"
#include "app/app.h"
#include "app/console.h"
#include "app/i18n/strings.h"
#include "app/resource_finder.h"
#include "base/bind.h"
#include "base/fs.h"
@ -56,7 +58,7 @@ std::string SendCrash::notificationText()
void SendCrash::notificationClick()
{
if (m_dumpFilename.empty()) {
ui::Alert::show("Crash Report<<Nothing to report||&OK");
ui::Alert::show(Strings::alerts_nothing_to_report());
return;
}
@ -83,7 +85,7 @@ void SendCrash::notificationClick()
m_dumpFilename = "";
}
catch (const std::exception& ex) {
ui::Alert::show("Error<<%s||&OK", ex.what());
Console::showException(ex);
}
}
}

View File

@ -28,6 +28,7 @@
#include "app/context_access.h"
#include "app/document_api.h"
#include "app/document_undo.h"
#include "app/i18n/strings.h"
#include "app/ini_file.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
@ -599,11 +600,7 @@ void ColorBar::onRemapButtonClick()
// Check the remap
if (!remap.isFor8bit() &&
Alert::show(
"Automatic Remap"
"<<The remap operation cannot be perfectly done for more than 256 colors."
"<<Do you want to continue anyway?"
"||&OK||&Cancel") != 1) {
Alert::show(Strings::alerts_auto_remap()) != 1) {
return;
}

View File

@ -13,12 +13,14 @@
#include "app/app_menus.h"
#include "app/crash/data_recovery.h"
#include "app/crash/session.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/ui/drop_down_button.h"
#include "app/ui/separator_in_view.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui/workspace.h"
#include "base/bind.h"
#include "fmt/format.h"
#include "ui/alert.h"
#include "ui/button.h"
#include "ui/entry.h"
@ -224,10 +226,9 @@ void DataRecoveryView::onDelete()
return;
// Delete one backup
if (Alert::show(PACKAGE
"<<Do you really want to delete the selected %d backup(s)?"
"||&Yes||&No",
int(items.size())) != 1)
if (Alert::show(
fmt::format(Strings::alerts_delete_selected_backups(),
int(items.size()))) != 1)
return; // Cancel
for (auto item : items) {

View File

@ -19,6 +19,7 @@
#include "app/console.h"
#include "app/context_access.h"
#include "app/document_access.h"
#include "app/i18n/strings.h"
#include "app/modules/editors.h"
#include "app/modules/palettes.h"
#include "app/pref/preferences.h"
@ -37,6 +38,7 @@
#include "doc/document_event.h"
#include "doc/layer.h"
#include "doc/sprite.h"
#include "fmt/format.h"
#include "ui/accelerator.h"
#include "ui/alert.h"
#include "ui/menu.h"
@ -278,12 +280,12 @@ bool DocumentView::onCloseView(Workspace* workspace, bool quitting)
// see if the sprite has changes
while (m_document->isModified()) {
// ask what want to do the user with the changes in the sprite
int ret = Alert::show("Warning"
"<<Saving changes to the sprite"
"<<\"%s\" before %s?"
"||&Save||Do&n't Save||&Cancel",
m_document->name().c_str(),
quitting ? "quitting": "closing");
int ret = Alert::show(
fmt::format(
Strings::alerts_save_sprite_changes(),
m_document->name(),
(quitting ? Strings::alerts_save_sprite_changes_quitting():
Strings::alerts_save_sprite_changes_closing())));
if (ret == 1) {
// "save": save the changes

View File

@ -20,6 +20,7 @@
#include "app/context.h"
#include "app/context_access.h"
#include "app/document_undo.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
#include "app/pref/preferences.h"
@ -48,6 +49,7 @@
#include "doc/remap.h"
#include "doc/slice.h"
#include "doc/sprite.h"
#include "fmt/format.h"
#include "render/dithering.h"
#include "render/render.h"
#include "ui/ui.h"
@ -591,10 +593,7 @@ tools::ToolLoop* create_tool_loop(
app::Color bg = colorbar->getBgColor();
if (!fg.isValid() || !bg.isValid()) {
Alert::show(PACKAGE
"<<The current selected foreground and/or background color"
"<<is out of range. Select a valid color in the color-bar."
"||&Close");
Alert::show(Strings::alerts_invalid_fg_or_bg_colors());
return NULL;
}
@ -626,11 +625,7 @@ tools::ToolLoop* create_tool_loop(
saveLastPoint);
}
catch (const std::exception& ex) {
Alert::show(PACKAGE
"<<Error drawing ink:"
"<<%s"
"||&Close",
ex.what());
Console::showException(ex);
return NULL;
}
}

View File

@ -10,11 +10,10 @@
#include "app/ui/file_selector.h"
#include "base/bind.h"
#include "base/string.h"
#include "app/app.h"
#include "app/console.h"
#include "app/file/file.h"
#include "app/i18n/strings.h"
#include "app/ini_file.h"
#include "app/modules/gfx.h"
#include "app/modules/gui.h"
@ -24,10 +23,13 @@
#include "app/ui/skin/skin_theme.h"
#include "app/widget_loader.h"
#include "base/bind.h"
#include "base/bind.h"
#include "base/convert_to.h"
#include "base/fs.h"
#include "base/split_string.h"
#include "base/string.h"
#include "base/unique_ptr.h"
#include "fmt/format.h"
#include "ui/ui.h"
#include "new_folder_window.xml.h"
@ -625,13 +627,17 @@ again:
fn.find('|') != std::string::npos);
#endif
if (has_invalid_char) {
Alert::show("Error"
"<<The file name cannot contain the following character(s):"
"<< /"
const char* invalid_chars =
"/"
#ifdef _WIN32
" \\ : * ? \" < > |"
" \\ : * ? \" < > |"
#endif
"||&OK");
;
ui::Alert::show(
fmt::format(
Strings::alerts_invalid_chars_in_filename(),
invalid_chars));
// show the window again
setVisible(true);
@ -646,8 +652,10 @@ again:
}
if (m_type == FileSelectorType::Save && base::is_file(buf)) {
int ret = Alert::show("Warning<<File exists, overwrite it?<<%s||&Yes||&No||&Cancel",
base::get_file_name(buf).c_str());
int ret = Alert::show(
fmt::format(
Strings::alerts_overwrite_existent_file(),
base::get_file_name(buf)));
if (ret == 2) {
setVisible(true);
goto again;
@ -655,8 +663,7 @@ again:
else if (ret == 1) {
// Check for read-only attribute
if (base::has_readonly_attr(buf)) {
ui::Alert::show(
"Problem<<The selected file is read-only. Try with other file.||&Go back");
ui::Alert::show(Strings::alerts_cannot_save_in_read_only_file());
setVisible(true);
goto again;

View File

@ -3318,8 +3318,8 @@ void Timeline::dropRange(DropOp op)
moveRange(newFromRange);
}
catch (const std::exception& e) {
ui::Alert::show("Problem<<%s||&OK", e.what());
catch (const std::exception& ex) {
Console::showException(ex);
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2016 David Capello
// Copyright (C) 2016-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -10,6 +10,7 @@
#include "app/util/clipboard_native.h"
#include "app/i18n/strings.h"
#include "base/serialization.h"
#include "base/unique_ptr.h"
#include "clip/clip.h"
@ -43,10 +44,10 @@ namespace {
void custom_error_handler(clip::ErrorCode code) {
switch (code) {
case clip::ErrorCode::CannotLock:
ui::Alert::show("Error<<Cannot access to the clipboard.\nMaybe other application is using it.||&OK");
ui::Alert::show(Strings::alerts_clipboard_access_locked());
break;
case clip::ErrorCode::ImageNotSupported:
ui::Alert::show("Error<<The current clipboard image format is not supported.||&OK");
ui::Alert::show(Strings::alerts_clipboard_image_format_not_supported());
break;
}
}

View File

@ -1,5 +1,5 @@
// Aseprite Code Generator
// Copyright (c) 2016 David Capello
// Copyright (c) 2016-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -54,7 +54,7 @@ void gen_strings_class(const std::string& inputFn)
for (auto key : keys) {
textId.append(key);
std::cout << " const std::string& " << to_cpp(textId) << "() const { return static_cast<T*>(this)->translate(\"" << textId << "\"); }\n";
std::cout << " static const std::string& " << to_cpp(textId) << "() { return T::instance()->translate(\"" << textId << "\"); }\n";
textId.erase(section.size()+1);
}

View File

@ -45,7 +45,6 @@
#include "ui/slider.h"
#include "ui/theme.h"
#include <cstdarg>
#include <cstdio>
namespace ui {
@ -73,13 +72,10 @@ void Alert::setProgress(double progress)
m_progress->setValue(int(MID(0.0, progress * 100.0, 100.0)));
}
AlertPtr Alert::create(const char* format, ...)
// static
AlertPtr Alert::create(const std::string& _msg)
{
// Process arguments
std::va_list ap;
va_start(ap, format);
std::string msg = base::string_vprintf(format, ap);
va_end(ap);
std::string msg(_msg);
// Create the alert window
AlertPtr window(new Alert());
@ -88,13 +84,9 @@ AlertPtr Alert::create(const char* format, ...)
}
// static
int Alert::show(const char* format, ...)
int Alert::show(const std::string& _msg)
{
// Process arguments
std::va_list ap;
va_start(ap, format);
std::string msg = base::string_vprintf(format, ap);
va_end(ap);
std::string msg(_msg);
// Create the alert window
AlertPtr window(new Alert());
@ -134,7 +126,14 @@ void Alert::processString(std::string& buf)
// Process buffer
c = 0;
beg = 0;
for (; ; c++) {
for (;;) {
// Ignore characters
if (buf[c] == '\n' ||
buf[c] == '\r') {
buf.erase(c, 1);
continue;
}
if ((!buf[c]) ||
((buf[c] == buf[c+1]) &&
((buf[c] == '<') ||
@ -185,9 +184,10 @@ void Alert::processString(std::string& buf)
case '-': separator=true; break;
case '|': button=true; break;
}
c++;
++c;
}
}
++c;
}
auto box1 = new Box(VERTICAL);

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -31,8 +31,8 @@ namespace ui {
int show();
static AlertPtr create(const char* format, ...);
static int show(const char* format, ...);
static AlertPtr create(const std::string& msg);
static int show(const std::string& msg);
private:
void processString(std::string& buf);