Sub language dependency removed


Subject: Sub language dependency removed
From: Henrik Berg (henrik@lansen.se)
Date: Thu Dec 09 1999 - 13:33:21 CST


With this patch language can be found on 'main' language if specific language is missing. This means that if you have "EsMX" for Mexican spanish and there is no translation for this, you will get first found "Es??" for both Menu_LabelSet and Toolbar_LabelSet.

With "StringSet" it's a little bit differerent, it's not good to start searching for Es??.string, so my patch search for Es.string if EsMX.string is not found. To use this all ????.string files must be renamed ??.string in the next package release.

This is a start for a better language detection on Win32 that I'm working on. But without some default/fallback to main language it's hard to make it good.

diff -u -r -N --minimal abi.org/src/wp/ap/beos/ap_BeOSApp.cpp abi/src/wp/ap/beos/ap_BeOSApp.cpp
--- abi.org/src/wp/ap/beos/ap_BeOSApp.cpp Sun Nov 28 16:43:40 1999
+++ abi/src/wp/ap/beos/ap_BeOSApp.cpp Thu Dec 9 20:20:12 1999
@@ -271,8 +271,27 @@
    }
    else
    {
- DELETEP(pDiskStringSet);
- UT_DEBUGMSG(("Unable to load StringSet [%s] -- using builtin strings instead.\n",szPathname));
+ char szShortStringSet[3];
+
+ strncpy(szShortStringSet,szStringSet,sizeof(szShortStringSet)-1);
+ szShortStringSet[sizeof(szShortStringSet)-1] = '\0';
+
+ sprintf(szPathname,"%s%s%s.strings",
+ szDirectory,
+ ((szDirectory[strlen(szDirectory)-1]=='/') ? "" : "/"),
+ szShortStringSet);
+
+ if (pDiskStringSet->loadStringsFromDisk(szPathname))
+ {
+ pDiskStringSet->setFallbackStringSet(m_pStringSet);
+ m_pStringSet = pDiskStringSet;
+ UT_DEBUGMSG(("Using StringSet [%s]\n",szPathname));
+ }
+ else
+ {
+ DELETEP(pDiskStringSet);
+ UT_DEBUGMSG(("Unable to load StringSet [%s] -- using builtin strings instead.\n",szPathname));
+ }
    }
     
    free(szPathname);
diff -u -r -N --minimal abi.org/src/wp/ap/unix/ap_UnixApp.cpp abi/src/wp/ap/unix/ap_UnixApp.cpp
--- abi.org/src/wp/ap/unix/ap_UnixApp.cpp Fri Dec 3 13:42:16 1999
+++ abi/src/wp/ap/unix/ap_UnixApp.cpp Thu Dec 9 20:20:18 1999
@@ -214,8 +214,27 @@
    }
    else
    {
- DELETEP(pDiskStringSet);
- UT_DEBUGMSG(("Unable to load StringSet [%s] -- using builtin strings instead.\n",szPathname));
+ char szShortStringSet[3];
+
+ strncpy(szShortStringSet,szStringSet,sizeof(szShortStringSet)-1);
+ szShortStringSet[sizeof(szShortStringSet)-1] = '\0';
+
+ sprintf(szPathname,"%s%s%s.strings",
+ szDirectory,
+ ((szDirectory[strlen(szDirectory)-1]=='/') ? "" : "/"),
+ szShortStringSet);
+
+ if (pDiskStringSet->loadStringsFromDisk(szPathname))
+ {
+ pDiskStringSet->setFallbackStringSet(m_pStringSet);
+ m_pStringSet = pDiskStringSet;
+ UT_DEBUGMSG(("Using StringSet [%s]\n",szPathname));
+ }
+ else
+ {
+ DELETEP(pDiskStringSet);
+ UT_DEBUGMSG(("Unable to load StringSet [%s] -- using builtin strings instead.\n",szPathname));
+ }
    }
     
    free(szPathname);
diff -u -r -N --minimal abi.org/src/wp/ap/win/ap_Win32App.cpp abi/src/wp/ap/win/ap_Win32App.cpp
--- abi.org/src/wp/ap/win/ap_Win32App.cpp Sun Nov 28 16:44:18 1999
+++ abi/src/wp/ap/win/ap_Win32App.cpp Thu Dec 9 20:20:04 1999
@@ -200,8 +200,27 @@
    }
    else
    {
- DELETEP(pDiskStringSet);
- UT_DEBUGMSG(("Unable to load StringSet [%s] -- using builtin strings instead.\n",szPathname));
+ char szShortStringSet[3];
+
+ strncpy(szShortStringSet,szStringSet,sizeof(szShortStringSet)-1);
+ szShortStringSet[sizeof(szShortStringSet)-1] = '\0';
+
+ sprintf(szPathname,"%s%s%s.strings",
+ szDirectory,
+ ((szDirectory[strlen(szDirectory)-1]=='\\') ? "" : "\\"),
+ szShortStringSet);
+
+ if (pDiskStringSet->loadStringsFromDisk(szPathname))
+ {
+ pDiskStringSet->setFallbackStringSet(m_pStringSet);
+ m_pStringSet = pDiskStringSet;
+ UT_DEBUGMSG(("Using StringSet [%s]\n",szPathname));
+ }
+ else
+ {
+ DELETEP(pDiskStringSet);
+ UT_DEBUGMSG(("Unable to load StringSet [%s] -- using builtin strings instead.\n",szPathname));
+ }
    }
     
    free(szPathname);
diff -u -r -N --minimal abi.org/src/wp/ap/xp/ap_Menu_LabelSet.cpp abi/src/wp/ap/xp/ap_Menu_LabelSet.cpp
--- abi.org/src/wp/ap/xp/ap_Menu_LabelSet.cpp Tue Apr 6 20:44:16 1999
+++ abi/src/wp/ap/xp/ap_Menu_LabelSet.cpp Thu Dec 9 19:02:12 1999
@@ -89,10 +89,18 @@
 
 EV_Menu_LabelSet * AP_CreateMenuLabelSet(const char * szLanguage)
 {
- if (szLanguage && *szLanguage)
- for (UT_uint32 k=0; k<NrElements(s_ltTable); k++)
+ if (szLanguage && *szLanguage)
+ {
+ UT_uint32 k;
+
+ for (k=0; k<NrElements(s_ltTable); k++)
    if (UT_stricmp(szLanguage,s_ltTable[k].m_name)==0)
- return (s_ltTable[k].m_fn)();
+ return (s_ltTable[k].m_fn)();
+
+ for (k=0; k<NrElements(s_ltTable); k++)
+ if (UT_strnicmp(szLanguage,s_ltTable[k].m_name,2)==0)
+ return (s_ltTable[k].m_fn)();
+ }
 
  // we fall back to EnUS if they didn't give us a valid language name.
  
diff -u -r -N --minimal abi.org/src/wp/ap/xp/ap_Toolbar_LabelSet.cpp abi/src/wp/ap/xp/ap_Toolbar_LabelSet.cpp
--- abi.org/src/wp/ap/xp/ap_Toolbar_LabelSet.cpp Wed Mar 31 17:42:44 1999
+++ abi/src/wp/ap/xp/ap_Toolbar_LabelSet.cpp Thu Dec 9 19:02:18 1999
@@ -92,10 +92,18 @@
 
 EV_Toolbar_LabelSet * AP_CreateToolbarLabelSet(const char * szLanguage)
 {
- if (szLanguage && *szLanguage)
- for (UT_uint32 k=0; k<NrElements(s_ltTable); k++)
+ if (szLanguage && *szLanguage)
+ {
+ UT_uint32 k;
+
+ for (k=0; k<NrElements(s_ltTable); k++)
    if (UT_stricmp(szLanguage,s_ltTable[k].m_name)==0)
- return (s_ltTable[k].m_fn)();
+ return (s_ltTable[k].m_fn)();
+
+ for (k=0; k<NrElements(s_ltTable); k++)
+ if (UT_strnicmp(szLanguage,s_ltTable[k].m_name,2)==0)
+ return (s_ltTable[k].m_fn)();
+ }
 
  // we fall back to EnUS if they didn't give us a valid language name.
  




This archive was generated by hypermail 2b25 : Thu Dec 09 1999 - 13:44:33 CST