Skip to content

Commit

Permalink
Start using fmt library
Browse files Browse the repository at this point in the history
This is the first step for a full i18n (aseprite#124).
  • Loading branch information
dacap committed Oct 9, 2017
1 parent aa95ccd commit f4ffd41
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
[submodule "third_party/giflib"]
path = third_party/giflib
url = https://github.com/aseprite/giflib.git
[submodule "third_party/fmt"]
path = third_party/fmt
url = https://github.com/aseprite/fmt.git
28 changes: 28 additions & 0 deletions docs/LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,34 @@ be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization of the copyright holder.
```

# [fmt](https://github.com/fmtlib/fmt)

```
Copyright (c) 2012 - 2016, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

# [FreeType](http://www.freetype.org/)

```
Expand Down
3 changes: 2 additions & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ target_link_libraries(app-lib
${FREETYPE_LIBRARIES}
${HARFBUZZ_LIBRARIES}
json11
archive_static)
archive_static
fmt)

if(ENABLE_SCRIPTING)
target_link_libraries(app-lib script-lib)
Expand Down
4 changes: 1 addition & 3 deletions src/app/i18n/strings.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -29,8 +29,6 @@ namespace app {
std::unordered_map<std::string, std::string> m_strings;
};

#define tr(id) (Strings::instance()->translate(id))

} // namespace app

#endif
6 changes: 4 additions & 2 deletions src/app/ui/home_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "app/ui_context.h"
#include "base/bind.h"
#include "base/exception.h"
#include "fmt/format.h"
#include "ui/label.h"
#include "ui/resize_event.h"
#include "ui/system.h"
Expand Down Expand Up @@ -143,15 +144,16 @@ void HomeView::onCheckingUpdates()

void HomeView::onUpToDate()
{
checkUpdate()->setText(PACKAGE " is up to date");
checkUpdate()->setText(fmt::format("{0} is up to date", PACKAGE));
checkUpdate()->setVisible(true);

layout();
}

void HomeView::onNewUpdate(const std::string& url, const std::string& version)
{
checkUpdate()->setText("New " PACKAGE " v" + version + " available!");
checkUpdate()->setText(fmt::format("New {0} v{1} available!",
PACKAGE, version));
checkUpdate()->setUrl(url);
checkUpdate()->setVisible(true);
checkUpdate()->InitTheme.connect(
Expand Down
1 change: 1 addition & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ endif()

add_subdirectory(harfbuzz-cmake)
add_subdirectory(simpleini)
add_subdirectory(fmt)

# Add cmark without tests
if(NOT USE_SHARED_CMARK)
Expand Down
1 change: 1 addition & 0 deletions third_party/fmt
Submodule fmt added at 933a33

0 comments on commit f4ffd41

Please sign in to comment.