Skip to content

Commit

Permalink
Raspberry fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin committed Jun 13, 2016
1 parent 902e80b commit c786c7c
Show file tree
Hide file tree
Showing 15 changed files with 3,304 additions and 14 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ project(locales C)
cmake_minimum_required(VERSION 2.8)
include(GNUInstallDirs)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
configure_file(config.h.in config.h)
configure_file(locale.in 00locale.sh)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
set(GETTEXT_PACKAGE "musl-locales")
set(MUSL_LOCPATH ${CMAKE_INSTALL_DATAROOTDIR}/i18n/locales/musl CACHE PATH "Locales directory" FORCE)
configure_file(config.h.in config.h)
configure_file(locale.in 00locale.sh)
set(LOCALE_SOURCES locale.c categories.c categories.h config.h)
add_executable(locale ${LOCALE_SOURCES})
install(PROGRAMS 00locale.sh DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/profile.d")
target_compile_options(locale
PRIVATE $<$<COMPILE_LANGUAGE:C>:-std=gnu11 -Wno-pedantic>
)
install(PROGRAMS ${CMAKE_BINARY_DIR}/00locale.sh DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/profile.d")
install(TARGETS locale DESTINATION bin)
add_subdirectory(po)
add_subdirectory(musl-po)
2 changes: 1 addition & 1 deletion cmake/Translations.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ macro (add_translations_directory NLS_PACKAGE)
# be sure that all languages are present
# Using all usual languages code from https://www.gnu.org/software/gettext/manual/html_node/Language-Codes.html#Language-Codes
# Rare language codes should be added on-demand.
set (LANGUAGES_NEEDED ru)
set (LANGUAGES_NEEDED en ru)
string (REPLACE ";" " " LINGUAS "${LANGUAGES_NEEDED}")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/LINGUAS.in ${CMAKE_CURRENT_BINARY_DIR}/LINGUAS)
foreach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED})
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#define PACKAGE "@GETTEXT_PACKAGE@"
#define LOCALEDIR "@CMAKE_INSTALL_FULL_DATAROOTDIR@/locale"
14 changes: 8 additions & 6 deletions locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ static void usage(char *name)

s = basename(name);
fprintf(stderr,
"Usage: %s [-a | -m] [FORMAT] name...\n\n"
gettext ("Usage: %s [-a | -m] [FORMAT] name...\n\n"
"\t-a, --all-locales\tWrite names of all available locales\n"
"\t-m, --charmaps\tWrite names of available charmaps\n"
"\nFORMAT:\n"
"\t-c, --category-name\tWrite names of selected categories\n"
"\t-k, --keyword-name\tWrite names of selected keywords\n"
, s);
), s);
}

static int argp_parse(int argc, char *argv[])
Expand Down Expand Up @@ -89,12 +89,12 @@ static int argp_parse(int argc, char *argv[])
show_usage = 1;
break;
case '?':
fprintf(stderr, "Unknown option.\n");
fprintf(stderr, gettext("Unknown option.\n"));
usage(progname);
return 1;

default:
fprintf(stderr, "This should never happen!\n");
fprintf(stderr, gettext("This should never happen!\n"));
return 1;
}

Expand All @@ -112,7 +112,8 @@ static void list_locale()
DIR *dir = opendir(locpath);
struct dirent *pDir;
while ((pDir = readdir(dir)) != NULL){
printf("%s.%s\n",pDir->d_name,"utf8");
if (strcmp(pDir->d_name,".") && strcmp(pDir->d_name,".."))
printf("%s\n",pDir->d_name);
}
}
}
Expand Down Expand Up @@ -202,8 +203,9 @@ int main(int argc, char *argv[])
fprintf (stderr, gettext ("Cannot set LC_CTYPE to default locale"));
if (setlocale (LC_MESSAGES, "") == NULL)
fprintf (stderr, gettext ("Cannot set LC_MESSAGES to default locale"));
bindtextdomain(PACKAGE,LOCALEDIR);
textdomain(PACKAGE);
/* Parse and process arguments. */
textdomain (PACKAGE);
if (argp_parse(argc, argv))
return 1;

Expand Down
4 changes: 4 additions & 0 deletions musl-po/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include(TranslationsMusl)
add_musl_translations_directory("musl" "${MUSL_LOCPATH}")
add_musl_translations_catalog("musl"
../musl)
2 changes: 2 additions & 0 deletions musl-po/LOCALES
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en_US
ru_RU
Loading

0 comments on commit c786c7c

Please sign in to comment.