Skip to content

Commit c9218f6

Browse files
committed
small poc to use i18n
1 parent 03db699 commit c9218f6

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ option(USE_CONAN
2525
if(USE_CONAN)
2626
find_package(SDL2 REQUIRED CONFIG)
2727
find_package(SDL2_mixer REQUIRED CONFIG)
28+
find_package(Intl REQUIRED CONFIG) # i18n library
29+
find_package(Gettext REQUIRED CONFIG) # Extract translations
2830
else()
2931
find_package(PkgConfig REQUIRED)
3032
pkg_check_modules(SDL2 REQUIRED sdl2 SDL2_mixer)
33+
find_package(Intl REQUIRED)
34+
find_package(Gettext REQUIRED)
3135
endif()
3236

3337
set(CMAKE_CXX_STANDARD 11)
@@ -80,10 +84,11 @@ if(LINUX)
8084
endif()
8185

8286
if(USE_CONAN)
83-
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer)
87+
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer Intl::Intl)
8488
else()
8589
target_include_directories(${LIRI_EXECUTABLE_NAME} PUBLIC ${SDL2_INCLUDE_DIRS})
8690
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE ${SDL2_LINK_LIBRARIES})
91+
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE Intl::Intl)
8792
endif()
8893

8994
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE SimpleIni::SimpleIni)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ This version updates the version to the SDL2 and updates the code to build and r
2222
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
2323
alt="Get it on F-Droid"
2424
height="80">](https://f-droid.org/packages/org.liri.liri/)
25+
26+
27+
Create the pot file:
28+
xgettext --copyright-holder="This file is copyright:" --package-name=Li-ri --msgid-bugs-address=https://bugs.kde.org --from-code=UTF-8 -C src/*.cc src/*.h -o liri.pot

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class LiRi(ConanFile):
55
settings = "os", "compiler", "build_type", "arch"
6-
requires = "sdl/[~2.28.5]", "sdl_mixer/[~2.8.0]", "openssl/1.1.1w"
6+
requires = "sdl/[~2.28.5]", "sdl_mixer/[~2.8.0]", "openssl/1.1.1w", "libgettext/0.26" # maybe "gettext/0.26"
77

88
def layout(self):
99
cmake_layout(self)

src/menu.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#include <SDL2/SDL_timer.h> // for SDL_GetTicks, SDL_Delay
3737
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_ENTER, SDL_SetWindowF...
3838

39+
#include <libintl.h>
40+
3941
#include <array>
4042
#include <utility>
4143
#include "preference.h"
@@ -126,6 +128,7 @@ eMenu Menu::SDLMain()
126128
AddButton(0, T_play, 400, 229);
127129
DrawText(400, 306, T_scores, Sprites[fmenu].Image[0]);
128130
AddButton(1, T_scores, 400, 306);
131+
gettext("Scores");
129132
DrawText(400, 384, T_moptions, Sprites[fmenu].Image[0]);
130133
AddButton(2, T_moptions, 400, 384);
131134
DrawText(400, 461, T_quit, Sprites[fmenu].Image[0]);

0 commit comments

Comments
 (0)