Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[gettext] define use of the English string file, as the source language file #980

Merged
merged 1 commit into from

2 participants

@alanwww1
Collaborator

No description provided.

@alanwww1 alanwww1 merged commit 52f85ab into from
@jmarshallnz
Owner

If you don't want review, don't bother doing a pull request...

@alanwww1
Collaborator

OK. Sorry.
I thought it was pretty safe stuff with no necesarry to review.
Hope it is not a problem.

@jmarshallnz
Owner

It's not a problem - just push to master instead of creating a pull request if that's the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
16 xbmc/Application.cpp
@@ -741,11 +741,10 @@ bool CApplication::Create()
CLog::Log(LOGINFO, "load language info file: %s", strLangInfoPath.c_str());
g_langInfo.Load(strLangInfoPath);
- CStdString strLanguagePath;
- strLanguagePath.Format("special://xbmc/language/%s", strLanguage.c_str());
+ CStdString strLanguagePath = "special://xbmc/language/";
- CLog::Log(LOGINFO, "load language file from path: %s", strLanguagePath.c_str());
- if (!g_localizeStrings.Load(strLanguagePath))
+ CLog::Log(LOGINFO, "load %s language file, from path: %s", strLanguage.c_str(), strLanguagePath.c_str());
+ if (!g_localizeStrings.Load(strLanguagePath, strLanguage))
FatalErrorHandler(false, false, true);
// start the AudioEngine
@@ -1756,14 +1755,11 @@ void CApplication::LoadSkin(const SkinPtr& skin)
g_fontManager.LoadFonts(g_guiSettings.GetString("lookandfeel.font"));
// load in the skin strings
- CStdString langPath, skinEnglishPath;
+ CStdString langPath;
URIUtils::AddFileToFolder(skin->Path(), "language", langPath);
- URIUtils::AddFileToFolder(langPath, g_guiSettings.GetString("locale.language"), langPath);
+ URIUtils::AddSlashAtEnd(langPath);
- URIUtils::AddFileToFolder(skin->Path(), "language", skinEnglishPath);
- URIUtils::AddFileToFolder(skinEnglishPath, "English", skinEnglishPath);
-
- g_localizeStrings.LoadSkinStrings(langPath, skinEnglishPath);
+ g_localizeStrings.LoadSkinStrings(langPath, g_guiSettings.GetString("locale.language"));
g_SkinInfo->LoadIncludes();
View
7 xbmc/addons/Addon.cpp
@@ -344,12 +344,9 @@ void CAddon::BuildLibName(const cp_extension_t *extension)
bool CAddon::LoadStrings()
{
// Path where the language strings reside
- CStdString chosenPath;
- chosenPath.Format("resources/language/%s", g_guiSettings.GetString("locale.language").c_str());
- CStdString chosen = URIUtils::AddFileToFolder(m_props.path, chosenPath);
- CStdString fallback = URIUtils::AddFileToFolder(m_props.path, "resources/language/English");
+ CStdString chosenPath = URIUtils::AddFileToFolder(m_props.path, "resources/language/");
- m_hasStrings = m_strings.Load(chosen, fallback);
+ m_hasStrings = m_strings.Load(chosenPath, g_guiSettings.GetString("locale.language"));
return m_checkedStrings = true;
}
View
44 xbmc/guilib/LocalizeStrings.cpp
@@ -55,28 +55,28 @@ void CLocalizeStrings::ClearSkinStrings()
Clear(31000, 31999);
}
-bool CLocalizeStrings::LoadSkinStrings(const CStdString& path, const CStdString& fallbackPath)
+bool CLocalizeStrings::LoadSkinStrings(const CStdString& path, const CStdString& language)
{
ClearSkinStrings();
// load the skin strings in.
CStdString encoding;
- if (!LoadStr2Mem(path, encoding))
+ if (!LoadStr2Mem(path, language, encoding))
{
- if (path.Equals(fallbackPath)) // no fallback, nothing to do
+ if (language.Equals(SOURCE_LANGUAGE)) // no fallback, nothing to do
return false;
}
// load the fallback
- if (!path.Equals(fallbackPath))
- LoadStr2Mem(fallbackPath, encoding);
+ if (!language.Equals(SOURCE_LANGUAGE))
+ LoadStr2Mem(path, SOURCE_LANGUAGE, encoding);
return true;
}
-bool CLocalizeStrings::LoadStr2Mem(const CStdString &pathname_in, CStdString &encoding,
- uint32_t offset /* = 0 */)
+bool CLocalizeStrings::LoadStr2Mem(const CStdString &pathname_in, const CStdString &language,
+ CStdString &encoding, uint32_t offset /* = 0 */)
{
- CStdString pathname = CSpecialProtocol::TranslatePathConvertCase(pathname_in);
+ CStdString pathname = CSpecialProtocol::TranslatePathConvertCase(pathname_in + language);
if (!XFILE::CDirectory::Exists(pathname))
{
CLog::Log(LOGDEBUG,
@@ -85,10 +85,8 @@ bool CLocalizeStrings::LoadStr2Mem(const CStdString &pathname_in, CStdString &en
return false;
}
- URIUtils::RemoveSlashAtEnd(pathname);
- bool bIsSourceLanguage = URIUtils::GetFileName(pathname).Equals("english");;
-
- if (LoadPO(URIUtils::AddFileToFolder(pathname, "strings.po"), encoding, offset, bIsSourceLanguage))
+ if (LoadPO(URIUtils::AddFileToFolder(pathname, "strings.po"), encoding, offset,
+ language.Equals(SOURCE_LANGUAGE)))
return true;
CLog::Log(LOGDEBUG, "LocalizeStrings: no strings.po file exist at %s, fallback to strings.xml",
@@ -173,7 +171,7 @@ bool CLocalizeStrings::LoadXML(const CStdString &filename, CStdString &encoding,
const TiXmlElement *pChild = pRootElement->FirstChildElement("string");
while (pChild)
{
- // Load new style language file with id as attribute
+ // Load old style language file with id as attribute
const char* attrId=pChild->Attribute("id");
if (attrId && !pChild->NoChildren())
{
@@ -186,24 +184,24 @@ bool CLocalizeStrings::LoadXML(const CStdString &filename, CStdString &encoding,
return true;
}
-bool CLocalizeStrings::Load(const CStdString& strFileName, const CStdString& strFallbackFileName)
+bool CLocalizeStrings::Load(const CStdString& strPathName, const CStdString& strLanguage)
{
- bool bLoadFallback = !strFileName.Equals(strFallbackFileName);
+ bool bLoadFallback = !strLanguage.Equals(SOURCE_LANGUAGE);
CStdString encoding;
Clear();
- if (!LoadStr2Mem(strFileName, encoding))
+ if (!LoadStr2Mem(strPathName, strLanguage, encoding))
{
// try loading the fallback
- if (!bLoadFallback || !LoadStr2Mem(strFallbackFileName, encoding))
+ if (!bLoadFallback || !LoadStr2Mem(strPathName, SOURCE_LANGUAGE, encoding))
return false;
bLoadFallback = false;
}
if (bLoadFallback)
- LoadStr2Mem(strFallbackFileName, encoding);
+ LoadStr2Mem(strPathName, SOURCE_LANGUAGE, encoding);
CStdString encoding_thisfile = "ISO-8859-1";
// we have ANSI encoding for LocalizeStrings.cpp therefore we need to use this encoding
@@ -265,7 +263,7 @@ void CLocalizeStrings::Clear(uint32_t start, uint32_t end)
}
}
-uint32_t CLocalizeStrings::LoadBlock(const CStdString &id, const CStdString &path, const CStdString &fallbackPath)
+uint32_t CLocalizeStrings::LoadBlock(const CStdString &id, const CStdString &path, const CStdString &language)
{
iBlocks it = m_blocks.find(id);
if (it != m_blocks.end())
@@ -277,16 +275,16 @@ uint32_t CLocalizeStrings::LoadBlock(const CStdString &id, const CStdString &pat
// load the strings
CStdString encoding;
- bool success = LoadStr2Mem(path, encoding, offset);
+ bool success = LoadStr2Mem(path, language, encoding, offset);
if (!success)
{
- if (path.Equals(fallbackPath)) // no fallback, nothing to do
+ if (language.Equals(SOURCE_LANGUAGE)) // no fallback, nothing to do
return 0;
}
// load the fallback
- if (!path.Equals(fallbackPath))
- success |= LoadStr2Mem(fallbackPath, encoding, offset);
+ if (!language.Equals(SOURCE_LANGUAGE))
+ success |= LoadStr2Mem(path, SOURCE_LANGUAGE, encoding, offset);
return success ? offset : 0;
}
View
17 xbmc/guilib/LocalizeStrings.h
@@ -40,21 +40,24 @@
struct LocStr
{
-CStdString strTranslated;
-CStdString strOriginal;
+CStdString strTranslated; // string to be used in xbmc GUI
+CStdString strOriginal; // the original English string, the tranlsation is based on
};
+// The default fallback language is fixed to be English
+const CStdString SOURCE_LANGUAGE = "English";
+
class CLocalizeStrings
{
public:
CLocalizeStrings(void);
virtual ~CLocalizeStrings(void);
- bool Load(const CStdString& strFileName, const CStdString& strFallbackFileName="special://xbmc/language/english");
- bool LoadSkinStrings(const CStdString& path, const CStdString& fallbackPath);
+ bool Load(const CStdString& strPathName, const CStdString& strLanguage);
+ bool LoadSkinStrings(const CStdString& path, const CStdString& language);
void ClearSkinStrings();
const CStdString& Get(uint32_t code) const;
void Clear();
- uint32_t LoadBlock(const CStdString &id, const CStdString &path, const CStdString &fallbackPath);
+ uint32_t LoadBlock(const CStdString &id, const CStdString &path, const CStdString &language);
void ClearBlock(const CStdString &id);
protected:
void Clear(uint32_t start, uint32_t end);
@@ -62,11 +65,13 @@ class CLocalizeStrings
/*! \brief Loads language ids and strings to memory map m_strings.
* It tries to load a strings.po file first. If doesn't exist, it loads a strings.xml file instead.
\param pathname The directory name, where we look for the strings file.
+ \param language We load the strings for this language. Fallback language is always English.
\param encoding Encoding of the strings. For PO files we only use utf-8.
\param offset An offset value to place strings from the id value.
\return false if no strings.po or strings.xml file was loaded.
*/
- bool LoadStr2Mem(const CStdString &pathname, CStdString &encoding, uint32_t offset = 0);
+ bool LoadStr2Mem(const CStdString &pathname, const CStdString &language,
+ CStdString &encoding, uint32_t offset = 0);
/*! \brief Tries to load ids and strings from a strings.po file to m_strings map.
* It should only be called from the LoadStr2Mem function to have a fallback.
View
8 xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
@@ -440,16 +440,12 @@ unsigned int CGUIPythonWindowXML::LoadScriptStrings()
{
// Path where the language strings reside
CStdString pathToLanguageFile = m_scriptPath;
- CStdString pathToFallbackLanguageFile = m_scriptPath;
URIUtils::AddFileToFolder(pathToLanguageFile, "resources", pathToLanguageFile);
- URIUtils::AddFileToFolder(pathToFallbackLanguageFile, "resources", pathToFallbackLanguageFile);
URIUtils::AddFileToFolder(pathToLanguageFile, "language", pathToLanguageFile);
- URIUtils::AddFileToFolder(pathToFallbackLanguageFile, "language", pathToFallbackLanguageFile);
- URIUtils::AddFileToFolder(pathToLanguageFile, g_guiSettings.GetString("locale.language"), pathToLanguageFile);
- URIUtils::AddFileToFolder(pathToFallbackLanguageFile, "english", pathToFallbackLanguageFile);
+ URIUtils::AddSlashAtEnd(pathToLanguageFile);
// allocate a bunch of strings
- return g_localizeStrings.LoadBlock(m_scriptPath, pathToLanguageFile, pathToFallbackLanguageFile);
+ return g_localizeStrings.LoadBlock(m_scriptPath, pathToLanguageFile, g_guiSettings.GetString("locale.language"));
}
void CGUIPythonWindowXML::ClearScriptStrings()
View
4 xbmc/settings/GUISettings.cpp
@@ -1464,9 +1464,7 @@ bool CGUISettings::SetLanguage(const CStdString &strLanguage)
g_charsetConverter.reset();
- CStdString strLanguagePath;
- strLanguagePath.Format("special://xbmc/language/%s", strNewLanguage.c_str());
- if (!g_localizeStrings.Load(strLanguagePath))
+ if (!g_localizeStrings.Load("special://xbmc/language/", strNewLanguage))
return false;
// also tell our weather and skin to reload as these are localized
View
5 xbmc/settings/Settings.cpp
@@ -941,11 +941,8 @@ bool CSettings::LoadProfile(unsigned int index)
CLog::Log(LOGINFO, "load language info file:%s", strLangInfoPath.c_str());
g_langInfo.Load(strLangInfoPath);
- CStdString strLanguagePath;
- strLanguagePath.Format("special://xbmc/language/%s", strLanguage.c_str());
-
CButtonTranslator::GetInstance().Load(true);
- g_localizeStrings.Load(strLanguagePath);
+ g_localizeStrings.Load("special://xbmc/language/", strLanguage);
g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse"));
Something went wrong with that request. Please try again.