-
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.
This method call xgettext 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
288 additions
and
1 deletion.
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,12 @@ | ||
## i18n module xgettext | ||
|
||
There is a new `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,15 @@ | ||
project( | ||
'gettext extractor', | ||
'c', | ||
default_options: {'default_library': 'static'}, | ||
meson_version: '1.7.0', | ||
) | ||
|
||
if not find_program('xgettext', required: false).found() | ||
error('MESON_SKIP_TEST xgettext command not found') | ||
endif | ||
|
||
i18n = import('i18n') | ||
xgettext_args = ['-ktr', '--add-comments=TRANSLATOR:', '--from-code=UTF-8'] | ||
|
||
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 = i18n.xgettext('lib1', lib1, args: xgettext_args) | ||
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 = i18n.xgettext('lib2', lib2, args: xgettext_args) | ||
lib2_includes = include_directories('.') |
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,8 @@ | ||
#include <lib2.h> | ||
|
||
int main(void) | ||
{ | ||
say_something_else(); | ||
|
||
return 0; | ||
} |
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 @@ | ||
subdir('lib1') | ||
subdir('lib2') | ||
|
||
main = executable('say', 'main.c', link_with: [lib2], include_directories: lib2_includes) | ||
|
||
main_pot = i18n.xgettext('main', main, args: xgettext_args, install: true, install_dir: 'intl', install_tag: 'intl', recursive: true) |
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 @@ | ||
{ | ||
"installed": [ | ||
{ "type": "file", "file": "usr/intl/main.pot" } | ||
], | ||
"expect_skip_on_jobname": ["azure", "cygwin"] | ||
} |