[sword-svn] r2299 - in trunk: include locales.d src/keys tests

scribe at crosswire.org scribe at crosswire.org
Fri Apr 3 16:51:49 MST 2009


Author: scribe
Date: 2009-04-03 16:51:49 -0700 (Fri, 03 Apr 2009)
New Revision: 2299

Modified:
   trunk/include/versekey.h
   trunk/locales.d/he-utf8.conf
   trunk/locales.d/pt_BR-utf8.conf
   trunk/locales.d/ru_RU-utf8.conf
   trunk/src/keys/versekey.cpp
   trunk/tests/parsekey.cpp
Log:
Added locale validation in parsekey.  Probably not the best place
but not an entirely bad place for now.
Fixed a couple locale names.


Modified: trunk/include/versekey.h
===================================================================
--- trunk/include/versekey.h	2009-04-03 11:27:13 UTC (rev 2298)
+++ trunk/include/versekey.h	2009-04-03 23:51:49 UTC (rev 2299)
@@ -89,8 +89,6 @@
 	*/
 	int findindex(long *array, int size, long value);
 
-	void validateCurrentLocale() const;
-
 	mutable long lowerBound, upperBound;
 	mutable VerseKey *tmpClone;
 
@@ -415,7 +413,10 @@
 	virtual void setVersificationSystem(const char *name);
 	virtual const char *getVersificationSystem() const;
 
+	// DEBUG
+	void validateCurrentLocale() const;
 
+
 	// OPERATORS --------------------------------------------------------------------
 
 

Modified: trunk/locales.d/he-utf8.conf
===================================================================
--- trunk/locales.d/he-utf8.conf	2009-04-03 11:27:13 UTC (rev 2298)
+++ trunk/locales.d/he-utf8.conf	2009-04-03 23:51:49 UTC (rev 2299)
@@ -296,7 +296,7 @@
 אסתר=Esth
 איוב=Job
 תהילים=Ps
-משלי=20-
+משלי=Prov
 קוהלת=Eccl
 שיר השירים=Song
 איכה=Lam

Modified: trunk/locales.d/pt_BR-utf8.conf
===================================================================
--- trunk/locales.d/pt_BR-utf8.conf	2009-04-03 11:27:13 UTC (rev 2298)
+++ trunk/locales.d/pt_BR-utf8.conf	2009-04-03 23:51:49 UTC (rev 2299)
@@ -1,7 +1,7 @@
 [Meta]
 Name=pt_BR
 Description=Brazillian Portuguese
-Encoding=ISO8859-1
+Encoding=UTF-8
 
 [Text]
 Genesis=Gênesis

Modified: trunk/locales.d/ru_RU-utf8.conf
===================================================================
--- trunk/locales.d/ru_RU-utf8.conf	2009-04-03 11:27:13 UTC (rev 2298)
+++ trunk/locales.d/ru_RU-utf8.conf	2009-04-03 23:51:49 UTC (rev 2299)
@@ -6,7 +6,7 @@
 # Converted with iconv by Martin Gruner
 
 [Meta]
-Name=ru
+Name=ru_RU
 Description=Russian (Unicode)
 Encoding=UTF-8
 

Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp	2009-04-03 11:27:13 UTC (rev 2298)
+++ trunk/src/keys/versekey.cpp	2009-04-03 23:51:49 UTC (rev 2299)
@@ -386,30 +386,24 @@
  */
 void VerseKey::validateCurrentLocale() const {
 	if (SWLog::getSystemLog()->getLogLevel() >= SWLog::LOG_DEBUG) { //make sure log is wanted, this loop stuff costs a lot of time
-		for (int t = 0; t < 2; t++) {
-			for (int i = 0; i < BMAX[t]; i++) {
-				const int bn = getBookAbbrev(
-						getPrivateLocale()->translate(refSys->getBook(((t>1)?BMAX[0]:0)+i-1)->getLongName())
-					);
-				if ((bn)%39 != i) {
-					char *abbr = 0;
-					stdstr(&abbr, 
-						getPrivateLocale()->translate(refSys->getBook(((t>1)?BMAX[0]:0)+i-1)->getLongName()), 2);
-					strstrip(abbr);
-					SWLog::getSystemLog()->logDebug("VerseKey::Book: %s does not have a matching toupper abbrevs entry! book number returned was: %d(%d). Required entry should be:",
-						abbr, bn, i);
+		for (int i = 0; i < refSys->getBookCount(); i++) {
+			const int bn = getBookAbbrev(getPrivateLocale()->translate(refSys->getBook(i)->getLongName()));
+			if (bn != i+1) {
+				char *abbr = 0;
+				stdstr(&abbr, getPrivateLocale()->translate(refSys->getBook(i)->getLongName()), 2);
+				strstrip(abbr);
+				SWLog::getSystemLog()->logDebug("VerseKey::Book: %s does not have a matching toupper abbrevs entry! book number returned was: %d, should be %d. Required entry to add to locale:", abbr, bn, i);
 
-					StringMgr* stringMgr = StringMgr::getSystemStringMgr();
-					const bool hasUTF8Support = StringMgr::hasUTF8Support();
-					if (hasUTF8Support) { //we have support for UTF-8 handling; we expect UTF-8 encoded locales
-						stringMgr->upperUTF8(abbr, strlen(abbr)*2);
-					}
-					else {
-						stringMgr->upperLatin1(abbr);
-					}
-					SWLog::getSystemLog()->logDebug("%s=%d", abbr, (t*39)+i+1);
-					delete [] abbr;
+				StringMgr* stringMgr = StringMgr::getSystemStringMgr();
+				const bool hasUTF8Support = StringMgr::hasUTF8Support();
+				if (hasUTF8Support) { //we have support for UTF-8 handling; we expect UTF-8 encoded locales
+					stringMgr->upperUTF8(abbr, strlen(abbr)*2);
 				}
+				else {
+					stringMgr->upperLatin1(abbr);
+				}
+				SWLog::getSystemLog()->logDebug("%s=%s\n", abbr, refSys->getBook(i)->getOSISName());
+				delete [] abbr;
 			}
 		}
 	}

Modified: trunk/tests/parsekey.cpp
===================================================================
--- trunk/tests/parsekey.cpp	2009-04-03 11:27:13 UTC (rev 2298)
+++ trunk/tests/parsekey.cpp	2009-04-03 23:51:49 UTC (rev 2299)
@@ -19,6 +19,8 @@
 
 #include <versekey.h>
 #include <localemgr.h>
+#include <swlog.h>
+
 #ifndef NO_SWORD_NAMESPACE
 using namespace sword;
 #endif
@@ -34,6 +36,9 @@
 
 	VerseKey DefaultVSKey;
 
+	SWLog::getSystemLog()->setLogLevel(SWLog::LOG_DEBUG);
+	DefaultVSKey.validateCurrentLocale();
+
 	DefaultVSKey = "jas3:1";
 	
 	ListKey verses = DefaultVSKey.ParseVerseList(argv[1], DefaultVSKey, true);




More information about the sword-cvs mailing list