-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f288374
commit 76e208e
Showing
16 changed files
with
146 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
*.la | ||
*.lo | ||
*.o | ||
*.pyc | ||
*~ | ||
|
||
**/.deps/ | ||
**/.dirstamp | ||
test-driver | ||
|
||
# / | ||
/autom4te.cache | ||
|
||
/compile | ||
/config.guess | ||
/config.status | ||
/config.sub | ||
/configure | ||
/depcomp | ||
/install-sh | ||
/libtool | ||
/ltmain.sh | ||
/missing | ||
/config.h | ||
/config.h.in | ||
/config.log | ||
/INSTALL | ||
Makefile | ||
Makefile.in | ||
|
||
/aclocal.m4 | ||
|
||
/*.pc | ||
*.res | ||
/src/hello_with_icu | ||
.vscode | ||
icuformat | ||
stamp-h1 | ||
/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 @@ | ||
export LOCALES_DIR=$(datadir)/$(PACKAGE_NAME)/locales | ||
|
||
SUBDIRS = src locales |
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 @@ | ||
AC_INIT([icuformat], [1.0], [none]) | ||
AM_INIT_AUTOMAKE([-Wall -Werror foreign]) | ||
AC_PROG_CXX | ||
AC_CONFIG_FILES([ | ||
Makefile | ||
src/Makefile | ||
locales/Makefile | ||
]) | ||
|
||
PKG_CHECK_MODULES(ICU, [icu-i18n, icu-io, icu-uc], CPPFLAGS="$CPPFLAGS $ICU_CFLAGS"; LIBS="$LIBS $ICU_LIBS") | ||
|
||
AC_OUTPUT |
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
root.res en.res: root.txt en.txt | ||
genrb -d . ./*.txt | ||
|
||
localesdir = $(LOCALES_DIR) | ||
dist_locales_DATA = root.res en.res |
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 |
---|---|---|
@@ -1,21 +1,4 @@ | ||
root { | ||
hello_message { "Hello World\n" } | ||
apertium_usage { | ||
"USAGE: {0} [-d datadir] [-f format] [-u] <direction> [in [out]]\n" | ||
" -d datadir directory of linguistic data\n" | ||
" -f format one of: txt (default), html, rtf, odt, odp, docx, wxml, xlsx, pptx,\n" | ||
" xpresstag, html-noent, html-alt, latex, latex-raw, line\n" | ||
" -a display ambiguity\n" | ||
" -u don\'t display marks \'*\' for unknown words\n" | ||
" -n don\'t insert period before possible sentence-ends\n" | ||
" -m memory.tmx use a translation memory to recycle translations\n" | ||
" -o direction translation direction using the translation memory,\n" | ||
" by default \'direction\' is used instead\n" | ||
" -l lists the available translation directions and exits\n" | ||
" -V print Apertium version\n" | ||
" -z force null-flush mode on all parts of the pipe\n" | ||
" direction typically, LANG1-LANG2, but see modes.xml in language data\n" | ||
" in input file (stdin by default)\n" | ||
" out output file (stdout by default)\n" | ||
} | ||
hello_message { "Hello World" } | ||
test_message { "Message for test" } | ||
} |
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,5 @@ | ||
bin_PROGRAMS = icuformat test | ||
icuformat_SOURCES = icuformat.cpp i18n.cpp | ||
test_SOURCES = test.cpp i18n.cpp | ||
|
||
AM_CPPFLAGS = -DLOCALES_DIR='"$(LOCALES_DIR)"' |
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,33 @@ | ||
#include <unicode/ustream.h> | ||
#include <unicode/resbund.h> | ||
#include <unicode/locid.h> | ||
#include <unicode/ustring.h> | ||
#include <unicode/msgfmt.h> | ||
#include "i18n.h" | ||
|
||
I18n::I18n() : resource(LOCALES_DIR, icu::Locale().getName(), status) | ||
{ | ||
if (!U_SUCCESS(status)) { | ||
std::cerr << "Error in accessing locales directory!" << std::endl; | ||
exit(EXIT_FAILURE); | ||
} | ||
} | ||
|
||
icu::UnicodeString I18n::format(const char* key) | ||
{ | ||
icu::UnicodeString output; | ||
|
||
icu::ResourceBundle pattern = resource.get(key, status); | ||
if (!U_SUCCESS(status)) { | ||
std::cerr << "Error: key not found!" << std::endl; | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
output = pattern.getString(status); | ||
if (!U_SUCCESS(status)) { | ||
std::cerr << "Error in getting key text!" << std::endl; | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
return output; | ||
} |
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,14 @@ | ||
#ifndef _I18N_ | ||
#define _I18N_ | ||
#include <unicode/resbund.h> | ||
#include <unicode/ustring.h> | ||
|
||
class I18n { | ||
private: | ||
icu::ResourceBundle resource; | ||
UErrorCode status = U_ZERO_ERROR; | ||
public: | ||
I18n(); | ||
icu::UnicodeString format(const char* key); | ||
}; | ||
#endif |
Binary file not shown.
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,17 @@ | ||
#include <iostream> | ||
#include <unicode/ustream.h> | ||
#include "i18n.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
if (argc != 2) { | ||
std::cout << "USAGE: icuformat <key>\n"; | ||
return 0; | ||
} | ||
|
||
I18n i18n; | ||
|
||
std::cout << i18n.format(argv[1]) << std::endl; | ||
|
||
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,10 @@ | ||
#include <iostream> | ||
#include <unicode/ustream.h> | ||
#include "i18n.h" | ||
|
||
int main() { | ||
I18n i18n; | ||
|
||
std::cout << i18n.format("test_message") << std::endl; | ||
return 0; | ||
} |