-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New find_xgettext method to i18n module
This method return a XgettextProgram object used to extract translatable string from source files into a .pot translation template. It differs from a plain CustomTarget in three ways: - It accepts build targets as sources, and automatically resolves source files from those build targets; - It detects command lines that are too long, and writes, at config time, the list of source files into a text file to be consumed by the xgettext command; - It detects dependencies between pot extraction targets, based on the dependencies between source targets.
- Loading branch information
Showing
13 changed files
with
355 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## i18n module find_xgettext | ||
|
||
There is a new `find_xgettext` function in `i18n` module that acts as a | ||
wrapper around `xgettext`. It allows to extract strings to translate from | ||
source files. | ||
|
||
This function is convenient, because: | ||
- It can find the sources files from a build target; | ||
- It will use an intermediate file when the number of source files is too | ||
big to be handled directly from the command line; | ||
- It is able to get strings to translate from the dependencies of the given | ||
targets. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
project( | ||
'gettext extractor', | ||
'c', | ||
default_options: {'default_library': 'static'}, | ||
meson_version: '1.7.0', | ||
) | ||
|
||
i18n = import('i18n') | ||
xgettext = i18n.find_xgettext( | ||
args: ['-ktr', '--add-comments=TRANSLATOR:', '--from-code=UTF-8'], | ||
required: false, | ||
) | ||
|
||
if not xgettext.found() | ||
error('MESON_SKIP_TEST xgettext command not found') | ||
endif | ||
|
||
subdir('src') |
10 changes: 10 additions & 0 deletions
10
test cases/frameworks/38 gettext extractor/src/lib1/lib1.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "lib1.h" | ||
|
||
#include <stdio.h> | ||
|
||
#define tr(STRING) (STRING) | ||
|
||
void say_something(void) | ||
{ | ||
printf("%s\n", tr("Something!")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef LIB1_H | ||
#define LIB1_H | ||
|
||
void say_something(void); | ||
|
||
#endif |
3 changes: 3 additions & 0 deletions
3
test cases/frameworks/38 gettext extractor/src/lib1/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lib1 = library('mylib1', 'lib1.c') | ||
lib1_pot = xgettext.extract('lib1', lib1) | ||
lib1_includes = include_directories('.') |
13 changes: 13 additions & 0 deletions
13
test cases/frameworks/38 gettext extractor/src/lib2/lib2.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "lib2.h" | ||
|
||
#include <lib1.h> | ||
|
||
#include <stdio.h> | ||
|
||
#define tr(STRING) (STRING) | ||
|
||
void say_something_else(void) | ||
{ | ||
say_something(); | ||
printf("%s\n", tr("Something else!")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef LIB2_H | ||
#define LIB2_H | ||
|
||
void say_something_else(void); | ||
|
||
#endif |
3 changes: 3 additions & 0 deletions
3
test cases/frameworks/38 gettext extractor/src/lib2/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lib2 = library('mylib2', 'lib2.c', include_directories: lib1_includes, link_with: lib1) | ||
lib2_pot = xgettext.extract('lib2', lib2) | ||
lib2_includes = include_directories('.') |
Oops, something went wrong.