diff options
author | Michael Vogt <mvo@debian.org> | 2005-10-17 14:20:25 +0000 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2005-10-17 14:20:25 +0000 |
commit | c511502fcec38680fff2f27aec75908e348e5905 (patch) | |
tree | 113bdb52474c1111110da47939342c9fd2994f1a /apt-pkg/indexfile.cc | |
parent | 3226f06e15d6c9816c26e87bb58f5589b84a467b (diff) | |
parent | 422eeaaadf17904bf2f08cdf9e8998bec645097c (diff) |
* merged ddtp support
Patches applied:
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--base-0
tag of otavio@debian.org--2005/apt--ddtp--0.6--patch-14
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-1
* fixed a problem when it comes to the cache rebuilding
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-2
* try harder to get the correct language code
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-3
* fix for output of the description and the debTranslationsIndex::Exists()
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-4
* made the translation downloading work
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-5
* FindInCache() uses the correct file now
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-6
* don't throw any more warnings
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-7
* merged with otavoi
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-8
* merged with otavios branch
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-9
* code cleanups (thanks matt!), moved UsePackage before the description list build in pkgcachegen to catch MMap errors early
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-10
* added a BUGS file with known problem, added apt-cdrom support for translated package descriptions
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-11
* updated with mainline
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-12
* added README.ddtp
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-13
* merged with apt--mvo
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-14
* added DDTP::URL-Remap. KILL THIS FEATURE once ddtp support is offical
* michael.vogt@ubuntu.com--2005/apt--ddtp--0--patch-15
* remvoed the remap feature again, dosn't work anyway
* otavio@debian.org--2005/apt--ddtp--0.6--base-0
tag of apt@packages.debian.org/apt--main--0--patch-71
* otavio@debian.org--2005/apt--ddtp--0.6--patch-1
Port DDTP to APT 0.6 branch
* otavio@debian.org--2005/apt--ddtp--0.6--patch-2
Fix sintax error on apt-cache
* otavio@debian.org--2005/apt--ddtp--0.6--patch-3
Remove a unused var.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-4
Fix problems due APT and structural changes.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-5
Fix problems due APT and structural changes.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-6
Sync with apt@packages.debian.org/apt--main--0--patch-74
* otavio@debian.org--2005/apt--ddtp--0.6--patch-7
Sync with apt@packages.debian.org/apt--main--0--patch-75
* otavio@debian.org--2005/apt--ddtp--0.6--patch-8
Sync with apt--main--0--patch-76
* otavio@debian.org--2005/apt--ddtp--0.6--patch-9
Remote a changelog entry added by mistake while merging.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-10
Sync with apt--main--0--patch-78
* otavio@debian.org--2005/apt--ddtp--0.6--patch-11
Revert fixes changes to move these to apt--fixes--0 branch.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-12
Another fix included here by mistake. Moving it to apt--fixes--0 branch.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-13
Merge last changes from apt--main--0.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-14
Add FindInCache method to skip the rebuild of cache every time.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-15
Merge changes did by Michael Vogt to solve some rebuilding mistakes.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-16
Does't show Description twice
* otavio@debian.org--2005/apt--ddtp--0.6--patch-17
Merge last fixes did by Michael but preserve my version of apt-cache.cc fix.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-18
Revert changes did by mistake on translation files.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-19
Merge last changes did from upstream side.
* otavio@debian.org--2005/apt--ddtp--0.6--patch-20
Sync with apt--main--0--patch-87
Diffstat (limited to 'apt-pkg/indexfile.cc')
-rw-r--r-- | apt-pkg/indexfile.cc | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 49665161d..496e68b8b 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -12,8 +12,11 @@ #pragma implementation "apt-pkg/indexfile.h" #endif +#include <apt-pkg/configuration.h> #include <apt-pkg/indexfile.h> #include <apt-pkg/error.h> + +#include <clocale> /*}}}*/ // Global list of Item supported @@ -67,3 +70,60 @@ string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record, return string(); } /*}}}*/ +// IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool pkgIndexFile::TranslationsAvailable() +{ + const string Translation = _config->Find("APT::Acquire::Translation"); + + if (Translation.compare("none") != 0) + return CheckLanguageCode(LanguageCode().c_str()); + else + return false; +} + /*}}}*/ +// IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/ +// --------------------------------------------------------------------- +/* */ +/* common cases: de_DE, de_DE@euro, de_DE.UTF-8, de_DE.UTF-8@euro, + de_DE.ISO8859-1, tig_ER + more in /etc/gdm/locale.conf +*/ + +bool pkgIndexFile::CheckLanguageCode(const char *Lang) +{ + if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_')) + return true; + + if (strcmp(Lang,"C") != 0) + _error->Warning("Wrong language code %s", Lang); + + return false; +} + /*}}}*/ +// IndexFile::LanguageCode - Return the Language Code /*{{{*/ +// --------------------------------------------------------------------- +/* return the language code */ +string pkgIndexFile::LanguageCode() +{ + const string Translation = _config->Find("APT::Acquire::Translation"); + + if (Translation.compare("environment") == 0) + { + string lang = std::setlocale(LC_MESSAGES,NULL); + + // FIXME: this needs to be added + // we have a mapping of the language codes that contains all the language + // codes that need the country code as well + // (like pt_BR, pt_PT, sv_SE, zh_*, en_*) + + if(lang.size() > 2) + return lang.substr(0,2); + else + return lang; + } + else + return Translation; +} + /*}}}*/ |