startup language available on the all OS

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 31a814360a
commit 28bb7a67f7
  1. 4
      src/frameworks/UBFileSystemUtils.cpp
  2. 2
      src/frameworks/UBFileSystemUtils.h
  3. 69
      src/frameworks/UBPlatformUtils_mac.mm

@ -177,7 +177,7 @@ void UBFileSystemUtils::cleanupGhostTempFolders(const QString& templateString)
}
QStringList UBFileSystemUtils::allFiles(const QString& pDirPath)
QStringList UBFileSystemUtils::allFiles(const QString& pDirPath, bool isRecursive)
{
QStringList result;
if (pDirPath == "" || pDirPath == "." || pDirPath == "..")
@ -187,7 +187,7 @@ QStringList UBFileSystemUtils::allFiles(const QString& pDirPath)
foreach(QFileInfo dirContent, dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot , QDir::Name))
{
if (dirContent.isDir())
if (isRecursive && dirContent.isDir())
{
result << allFiles(dirContent.absoluteFilePath());
}

@ -37,7 +37,7 @@ class UBFileSystemUtils
static QFileInfoList allElementsInDirectory(const QString& pDirPath);
static QStringList allFiles(const QString& pDirPath);
static QStringList allFiles(const QString& pDirPath, const bool isRecurive=true);
static bool deleteDir(const QString& pDirPath);

@ -184,31 +184,64 @@ void UBPlatformUtils::fadeDisplayIn()
}
}
QString UBPlatformUtils::preferredTranslation(QString pFilePrefix)
{
QString qmPath;
NSString* filePrefix = [[NSString alloc] initWithUTF8String:(const char*)(pFilePrefix.toUtf8())];
//QString UBPlatformUtils::preferredTranslation(QString pFilePrefix)
//{
// QString qmPath;
// NSString* filePrefix = [[NSString alloc] initWithUTF8String:(const char*)(pFilePrefix.toUtf8())];
// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// NSString *lprojPath = [[[NSBundle mainBundle] pathForResource:@"Localizable" ofType:@"strings"] stringByDeletingLastPathComponent];
// if (lprojPath)
// {
// NSString *lang = [[lprojPath lastPathComponent] stringByDeletingPathExtension];
// NSString *translationFilePath = [lprojPath stringByAppendingPathComponent:[[filePrefix stringByAppendingString:lang] stringByAppendingPathExtension:@"qm"]];
// qmPath = QString::fromUtf8([translationFilePath UTF8String], strlen([translationFilePath UTF8String]));
// }
// [pool drain];
// return qmPath;
//}
//QString UBPlatformUtils::preferredLanguage()
//{
// QFileInfo qmFileInfo = QFileInfo(preferredTranslation("sankore_"));
// QDir lprojPath = qmFileInfo.dir();
// QFileInfo lprojFileInfo = QFileInfo(lprojPath.absolutePath());
// return lprojFileInfo.baseName();
//}
QStringList UBPlatformUtils::availableTranslations()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *lprojPath = [[NSBundle mainBundle] resourcePath];
QString translationsPath = QString::fromUtf8([lprojPath UTF8String], strlen([lprojPath UTF8String]));
QStringList translationsList = UBFileSystemUtils::allFiles(translationsPath, false);
QRegExp sankoreTranslationFiles(".*lproj");
translationsList=translationsList.filter(sankoreTranslationFiles);
[pool drain];
return translationsList.replaceInStrings(QRegExp("(.*)/(.*).lproj"),"\\2");
}
NSString *lprojPath = [[[NSBundle mainBundle] pathForResource:@"Localizable" ofType:@"strings"] stringByDeletingLastPathComponent];
if (lprojPath)
{
NSString *lang = [[lprojPath lastPathComponent] stringByDeletingPathExtension];
NSString *translationFilePath = [lprojPath stringByAppendingPathComponent:[[filePrefix stringByAppendingString:lang] stringByAppendingPathExtension:@"qm"]];
qmPath = QString::fromUtf8([translationFilePath UTF8String], strlen([translationFilePath UTF8String]));
}
QString UBPlatformUtils::translationPath(QString pFilePrefix, QString pLanguage)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *lprojPath = [[NSBundle mainBundle] resourcePath];
QString translationsPath = QString::fromUtf8([lprojPath UTF8String], strlen([lprojPath UTF8String]));
[pool drain];
return qmPath;
return translationsPath + "/" + pLanguage + ".lproj/" + pFilePrefix + pLanguage + ".qm";
}
QString UBPlatformUtils::preferredLanguage()
QString UBPlatformUtils::systemLanguage()
{
QFileInfo qmFileInfo = QFileInfo(preferredTranslation("sankore_"));
QDir lprojPath = qmFileInfo.dir();
QFileInfo lprojFileInfo = QFileInfo(lprojPath.absolutePath());
return lprojFileInfo.baseName();
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"AppleLanguages"];
NSString* preferredLang = [languages objectAtIndex:0];
QString result = QString::fromUtf8([preferredLang UTF8String], strlen([preferredLang UTF8String]));
[pool drain];
return result;
}
void UBPlatformUtils::runInstaller(const QString &installerFilePath)

Loading…
Cancel
Save