kopia lustrzana https://github.com/jamescoxon/dl-fldigi
Enable NLS on woe32
* Include .po files when building nsis installer * Store language preference in homedir/lang.txt on win32pull/2/head
rodzic
fe9ee31e4b
commit
0ad002e71c
|
@ -122,6 +122,9 @@ SectionEnd
|
|||
SetOutPath $INSTDIR
|
||||
File "${FLDIGI_BINARY}"
|
||||
File /nonfatal "${MINGWM_DLL}" "${PTW32_DLL}"
|
||||
!ifdef FLDIGI_LOCALE_DIR
|
||||
File /r "${FLDIGI_LOCALE_PATH}/${FLDIGI_LOCALE_DIR}"
|
||||
!endif
|
||||
StrCpy $WANT_FLDIGI "true"
|
||||
SectionEnd
|
||||
!endif
|
||||
|
@ -205,6 +208,9 @@ Section "Uninstall"
|
|||
# Remove files and uninstaller
|
||||
!ifdef HAVE_FLDIGI
|
||||
Delete /REBOOTOK $INSTDIR\${FLDIGI_BINARY}
|
||||
!ifdef FLDIGI_LOCALE_DIR
|
||||
RMDir /r /REBOOTOK $INSTDIR\${FLDIGI_LOCALE_DIR}
|
||||
!endif
|
||||
!endif
|
||||
!ifdef HAVE_FLARQ
|
||||
Delete /REBOOTOK $INSTDIR\${FLARQ_BINARY}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
### Script to create a win32 installer file
|
||||
### 20090510 Stelios Bounanos M0GLD
|
||||
### 20110209 Stelios Bounanos M0GLD
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Syntax: $0 data-dir build-dir" >&2
|
||||
|
@ -85,6 +85,10 @@ if ! test -r "$build/$PTW32_DLL"; then
|
|||
fi
|
||||
def="$def -DMINGWM_DLL=$MINGWM_DLL -DPTW32_DLL=$PTW32_DLL"
|
||||
|
||||
if test "x$USE_NLS" = "xyes" && make -C "$srcdir/../po" install prefix="$build" >/dev/null; then
|
||||
def="$def -DFLDIGI_LOCALE_PATH=$build/share -DFLDIGI_LOCALE_DIR=locale"
|
||||
fi
|
||||
|
||||
$MAKENSIS -V2 -NOCD -D"INSTALLER_FILE=$INSTALLER_FILE" -D"LICENSE_FILE=$data/../COPYING" \
|
||||
-D"SUPPORT_URL=$PACKAGE_HOME" -D"UPDATES_URL=$PACKAGE_DL" -D"FLDIGI_DOCS_URL=$PACKAGE_DOCS" \
|
||||
-D"FLARQ_DOCS_URL=$FLARQ_DOCS" -D"GUIDE_URL=$PACKAGE_GUIDE" $def "$data/win32/fldigi.nsi"
|
||||
|
|
|
@ -34,7 +34,7 @@ BENCHMARK_SRC = include/benchmark.h misc/benchmark.cxx
|
|||
REGEX_SRC = compat/regex.h compat/regex.c
|
||||
STACK_SRC = include/stack.h misc/stack.cxx
|
||||
MINGW32_SRC = include/compat.h compat/getsysinfo.c compat/mingw.c compat/mingw.h
|
||||
NLS_SRC = misc/nls.cxx
|
||||
NLS_SRC = misc/nls.cxx include/nls.h
|
||||
|
||||
# We distribute these but do not always compile them
|
||||
EXTRA_fldigi_SOURCES = $(HAMLIB_SRC) $(XMLRPC_SRC) $(FLDIGI_WIN32_RES_SRC) $(COMMON_WIN32_RES_SRC) \
|
||||
|
@ -206,6 +206,10 @@ nsisinst: $(bin_PROGRAMS)
|
|||
CLEANFILES += $(INSTALLER_FILE)
|
||||
endif
|
||||
|
||||
if USE_NLS
|
||||
CLEAN_LOCAL += share
|
||||
endif
|
||||
|
||||
if WANT_FLDIGI
|
||||
if ENABLE_HAMLIB
|
||||
hamlib-static: $(fldigi_OBJECTS)
|
||||
|
|
|
@ -143,6 +143,13 @@ mode_browser->show(&progdefaults.visible_modes);
|
|||
progdefaults.changed = true;
|
||||
}
|
||||
|
||||
Fl_Choice *mnuLang=(Fl_Choice *)0;
|
||||
|
||||
static void cb_mnuLang(Fl_Choice* o, void*) {
|
||||
progdefaults.ui_language = o->value();
|
||||
progdefaults.changed = true;
|
||||
}
|
||||
|
||||
Fl_Check_Button *btnNagMe=(Fl_Check_Button *)0;
|
||||
|
||||
static void cb_btnNagMe(Fl_Check_Button* o, void*) {
|
||||
|
@ -3005,13 +3012,13 @@ static const char szProsigns[] = "~|%|&|+|=|{|}|<|>|[|]| ";
|
|||
btnShowTooltips->callback((Fl_Callback*)cb_btnShowTooltips);
|
||||
o->value(progdefaults.tooltips);
|
||||
} // Fl_Check_Button* btnShowTooltips
|
||||
{ Fl_Check_Button* o = chkMenuIcons = new Fl_Check_Button(20, 87, 150, 20, _("Show menu icons"));
|
||||
{ Fl_Check_Button* o = chkMenuIcons = new Fl_Check_Button(155, 61, 150, 20, _("Show menu icons"));
|
||||
chkMenuIcons->tooltip(_("Enable / disable icons on menus"));
|
||||
chkMenuIcons->down_box(FL_DOWN_BOX);
|
||||
chkMenuIcons->callback((Fl_Callback*)cb_chkMenuIcons);
|
||||
o->value(progdefaults.menuicons);
|
||||
} // Fl_Check_Button* chkMenuIcons
|
||||
{ mnuScheme = new Fl_Choice(250, 61, 80, 20, _("UI scheme"));
|
||||
{ mnuScheme = new Fl_Choice(155, 87, 80, 20, _("UI scheme"));
|
||||
mnuScheme->tooltip(_("Change application look and feel"));
|
||||
mnuScheme->down_box(FL_BORDER_BOX);
|
||||
mnuScheme->callback((Fl_Callback*)cb_mnuScheme);
|
||||
|
@ -3021,10 +3028,16 @@ static const char szProsigns[] = "~|%|&|+|=|{|}|<|>|[|]| ";
|
|||
mnuScheme->add("plastic");
|
||||
mnuScheme->value(mnuScheme->find_item(progdefaults.ui_scheme.c_str()));
|
||||
} // Fl_Choice* mnuScheme
|
||||
{ bVisibleModes = new Fl_Button(250, 87, 120, 20, _("Visible modes"));
|
||||
{ bVisibleModes = new Fl_Button(20, 87, 110, 20, _("Visible modes"));
|
||||
bVisibleModes->tooltip(_("Select modes for menu access"));
|
||||
bVisibleModes->callback((Fl_Callback*)cb_bVisibleModes);
|
||||
} // Fl_Button* bVisibleModes
|
||||
{ mnuLang = new Fl_Choice(365, 87, 110, 20, _("UI language"));
|
||||
mnuLang->tooltip(_("Changes take effect on next program startup"));
|
||||
mnuLang->down_box(FL_BORDER_BOX);
|
||||
mnuLang->callback((Fl_Callback*)cb_mnuLang);
|
||||
mnuLang->align(FL_ALIGN_TOP_LEFT);
|
||||
} // Fl_Choice* mnuLang
|
||||
o->end();
|
||||
} // Fl_Group* o
|
||||
{ Fl_Group* o = new Fl_Group(2, 114, 496, 150, _("QSO logging"));
|
||||
|
|
|
@ -209,7 +209,7 @@ progdefaults.changed = true;}
|
|||
callback {progdefaults.menuicons = o->value();
|
||||
toggle_icon_labels();
|
||||
progdefaults.changed = true;}
|
||||
tooltip {Enable / disable icons on menus} xywh {20 87 150 20} down_box DOWN_BOX
|
||||
tooltip {Enable / disable icons on menus} xywh {155 61 150 20} down_box DOWN_BOX
|
||||
code0 {o->value(progdefaults.menuicons);}
|
||||
}
|
||||
Fl_Choice mnuScheme {
|
||||
|
@ -218,7 +218,7 @@ progdefaults.changed = true;}
|
|||
Fl::scheme(progdefaults.ui_scheme.c_str());
|
||||
|
||||
progdefaults.changed = true;} open
|
||||
tooltip {Change application look and feel} xywh {250 61 80 20} down_box BORDER_BOX align 8
|
||||
tooltip {Change application look and feel} xywh {155 87 80 20} down_box BORDER_BOX align 8
|
||||
code0 {mnuScheme->add("base");}
|
||||
code1 {mnuScheme->add("gtk+");}
|
||||
code2 {mnuScheme->add("plastic");}
|
||||
|
@ -230,8 +230,14 @@ progdefaults.changed = true;}
|
|||
mode_browser->callback(toggle_visible_modes);
|
||||
mode_browser->show(&progdefaults.visible_modes);
|
||||
progdefaults.changed = true;}
|
||||
tooltip {Select modes for menu access} xywh {250 87 120 20}
|
||||
tooltip {Select modes for menu access} xywh {20 87 110 20}
|
||||
}
|
||||
Fl_Choice mnuLang {
|
||||
label {UI language}
|
||||
callback {progdefaults.ui_language = o->value();
|
||||
progdefaults.changed = true;} open
|
||||
tooltip {Changes take effect on next program startup} xywh {365 87 110 20} down_box BORDER_BOX align 5
|
||||
} {}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label {QSO logging} open
|
||||
|
|
|
@ -36,6 +36,7 @@ extern Fl_Check_Button *chkMenuIcons;
|
|||
extern Fl_Choice *mnuScheme;
|
||||
#include <FL/Fl_Button.H>
|
||||
extern Fl_Button *bVisibleModes;
|
||||
extern Fl_Choice *mnuLang;
|
||||
extern Fl_Check_Button *btnNagMe;
|
||||
extern Fl_Check_Button *btnClearOnSave;
|
||||
extern Fl_Check_Button *btnAutoFillQSO;
|
||||
|
|
|
@ -1061,6 +1061,9 @@
|
|||
ELEM_(std::string, ui_scheme, "UISCHEME", \
|
||||
"FLTK UI scheme (none or base, gtk+, plastic)", \
|
||||
"gtk+") \
|
||||
ELEM_(int, ui_language, "UILANGUAGE", \
|
||||
"UI language", \
|
||||
0) \
|
||||
ELEM_(bool, wf_audioscale, "WFAUDIOSCALE", \
|
||||
"Always show audio frequencies on waterfall", \
|
||||
true) \
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef NLS_H_
|
||||
#define NLS_H_
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if ENABLE_NLS && defined(__WOE32__)
|
||||
struct lang_def_t {
|
||||
const char* lang;
|
||||
const char* lang_region;
|
||||
const char* native_name;
|
||||
int percent_done;
|
||||
};
|
||||
|
||||
extern struct lang_def_t ui_langs[];
|
||||
|
||||
int get_ui_lang(const char* homedir = NULL);
|
||||
void set_ui_lang(int lang, const char* homedir = NULL);
|
||||
#endif
|
||||
|
||||
#endif // NLS_H_
|
|
@ -33,6 +33,7 @@
|
|||
#include "fl_digi.h"
|
||||
#include "main.h"
|
||||
#include "gettext.h"
|
||||
#include "nls.h"
|
||||
#include "icons.h"
|
||||
|
||||
#if USE_HAMLIB
|
||||
|
@ -467,6 +468,10 @@ void configuration::saveDefaults()
|
|||
ViewerFontName = Fl::get_font_name(ViewerFontnbr);
|
||||
FreqControlFontName = Fl::get_font_name(FreqControlFontnbr);
|
||||
|
||||
#if ENABLE_NLS && defined(__WOE32__)
|
||||
set_ui_lang(mnuLang->value());
|
||||
#endif
|
||||
|
||||
writeDefaultsXML();
|
||||
changed = false;
|
||||
}
|
||||
|
@ -684,6 +689,19 @@ int configuration::setDefaults()
|
|||
btnUsePPortPTT->hide();
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS && defined(__WOE32__)
|
||||
ostringstream ss;
|
||||
for (lang_def_t* p = ui_langs; p->lang; p++) {
|
||||
ss.str("");
|
||||
ss << p->native_name << " (" << p->percent_done << "%)";
|
||||
mnuLang->add(ss.str().c_str());
|
||||
}
|
||||
mnuLang->value(get_ui_lang());
|
||||
mnuLang->show();
|
||||
#else
|
||||
mnuLang->hide();
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
// Copyright (C) 2008
|
||||
// Stéphane Fillod, F8CFE
|
||||
//
|
||||
// Copyright (C) 2011
|
||||
// Stelios Bounanos, M0GLD
|
||||
//
|
||||
// This file is part of fldigi.
|
||||
//
|
||||
// Fldigi is free software: you can redistribute it and/or modify
|
||||
|
@ -23,11 +26,83 @@
|
|||
#include <config.h>
|
||||
#include <locale.h>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "nls.h"
|
||||
#include "gettext.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef __WOE32__
|
||||
# ifndef PATH_MAX
|
||||
# define PATH_MAX 4096
|
||||
# endif
|
||||
|
||||
# include <string>
|
||||
# include <fstream>
|
||||
|
||||
// TODO: figure out the percentage automatically; hopefully not in a horribly kludgy way
|
||||
struct lang_def_t ui_langs[] = {
|
||||
{ "en", "en_US", "English", 100 },
|
||||
{ "fr", "fr_FR", "Fran\347ais", 38 },
|
||||
{ "it", "it_IT", "Italiano", 100 },
|
||||
{ "es", "es_ES", "Espa\361ol", 97 },
|
||||
{ NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static string get_win32_lang_dir(const char* homedir = NULL)
|
||||
{
|
||||
string lang_fn;
|
||||
if (!homedir) {
|
||||
if (!(homedir = getenv("USERPROFILE")))
|
||||
return lang_fn;
|
||||
lang_fn.assign(homedir).append("\\fldigi.files\\");
|
||||
}
|
||||
|
||||
return lang_fn.append("lang.txt");
|
||||
}
|
||||
|
||||
int get_ui_lang(const char* homedir)
|
||||
{
|
||||
string lang = get_win32_lang_dir(homedir);
|
||||
|
||||
ifstream in(lang.c_str());
|
||||
if (!in)
|
||||
return 0;
|
||||
|
||||
string::size_type u = string::npos;
|
||||
while (in >> lang) {
|
||||
if (lang[0] != '\n' & lang[0] != '#' && (u = lang.find('_')) != string::npos)
|
||||
break;
|
||||
}
|
||||
in.close();
|
||||
|
||||
if (u != string::npos)
|
||||
for (lang_def_t* p = ui_langs; p->lang; p++)
|
||||
if (lang == p->lang_region)
|
||||
return (int)(p - ui_langs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_ui_lang(int lang, const char* homedir)
|
||||
{
|
||||
if ((size_t)lang >= sizeof(ui_langs)/sizeof(*ui_langs) - 1)
|
||||
return;
|
||||
|
||||
string langfn = get_win32_lang_dir(homedir);
|
||||
ofstream f(langfn.c_str());
|
||||
if (f) {
|
||||
f << "# Autogenerated file, do not edit\r\n"
|
||||
<< ui_langs[lang].lang_region << "\r\n";
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int setup_nls(void)
|
||||
{
|
||||
static int nls_set_up = 0;
|
||||
|
@ -40,9 +115,13 @@ int setup_nls(void)
|
|||
// setting LC_NUMERIC might break the config read/write routines
|
||||
|
||||
const char* ldir;
|
||||
char buf[4096];
|
||||
char buf[PATH_MAX];
|
||||
if (!(ldir = getenv("FLDIGI_LOCALE_DIR"))) {
|
||||
if (getcwd(buf, sizeof(buf) - strlen("/locale") - 1)) {
|
||||
#ifdef __WOE32__
|
||||
int lang = get_ui_lang();
|
||||
setenv("LANGUAGE", ui_langs[lang].lang_region, 1);
|
||||
#endif
|
||||
strcpy(buf + strlen(buf), "/locale");
|
||||
struct stat s;
|
||||
if (stat(buf, &s) != -1 && S_ISDIR(s.st_mode))
|
||||
|
|
Ładowanie…
Reference in New Issue