summaryrefslogtreecommitdiff
path: root/apt-pkg/indexfile.cc
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2007-06-06 23:56:19 +0200
committerMichael Vogt <egon@bottom>2007-06-06 23:56:19 +0200
commit484dbb814fd2b787b2206ffe9504798dfd73ae6c (patch)
tree5ba4ad9d3364b5005416b7bc6d687230878c895f /apt-pkg/indexfile.cc
parentfaa6596e09eec9535189c5baa7a6d2d4531f9239 (diff)
parent0be7a32e21dca2e96ce46f6e5b701011aea76586 (diff)
* merged the debian/experimental changes back
into the debian/sid branch * merged from Christian Perrier: * mr.po: New Marathi translation Closes: #416806 * zh_CN.po: Updated by Eric Pareja Closes: #416822 * tl.po: Updated by Eric Pareja Closes: #416638 * gl.po: Updated by Jacobo Tarrio * da.po: Updated by Claus Hindsgaul * fr.po: Remove a non-breakable space for usability * ru.po: Updated Russian translation. Closes: #405476 * *.po: Unfuzzy after upstream typo corrections * buildlib/archtable: - added support for sh3/sh4 (closes: #424870) - added support for m32r (closes: #394096) * buildlib/systemtable: - added support for lpia * configure.in: - check systemtable for architecture mapping too * Package that contains tall the new features * Removed all #pragma interface/implementation * Branch that contains tall the new features: * translated package descriptions * task install support * automatic dependency removal (thanks to Daniel Burrows) * merged support for the new dpkg "Breaks" field (thanks to Ian Jackson) * handle network failures more gracefully on "update" * support for unattended-upgrades (via unattended-upgrades package) * added apt-transport-https method * merged "install-recommends" branch (ABI break): - new "--install-recommends" - install new recommends on "upgrade" if --install-recommends is given - new "--fix-policy" option to install all packages with unmet important dependencies (usefull with --install-recommends to see what not-installed recommends are on the system) - fix of recommended packages display (only show CandidateVersion fix or-group handling) * merged "install-task" branch (use with "apt-get install taskname^") * Applied patch from Daniel Schepler to make apt bin-NMU able. * eu.po: Updated * fix apt-get dist-upgrade * fix warning if no /var/lib/apt/extended_states is present * don't download Translations for deb-src sources.list lines * apt-pkg/tagfile.cc: - support not-mmapable files again * added support for i18n of the package descriptions * added support for aptitude like auto-install tracking (a HUGE HUGE thanks to Daniel Burrows who made this possible) * synced with the http://people.debian.org/~mvo/bzr/apt/debian-sid branch * build from http://people.debian.org/~mvo/bzr/apt/debian-experimental * apt-pkg/depcache.cc: - added Debug::pkgDepCache::AutoInstall (thanks to infinity) * apt-pkg/acquire-item.cc: - fix missing chmod() in the new aquire code (thanks to Bastian Blank, Closes: #367425) * merged from http://www.perrier.eu.org/debian/packages/d-i/level4/apt-main: * sk.po: Completed to 512t * eu.po: Completed to 512t * fr.po: Completed to 512t * sv.po: Completed to 512t * Update all PO and the POT. Gives 506t6f for formerly complete translations * Fix a incorrect example in the man-page (closes: #282918)
Diffstat (limited to 'apt-pkg/indexfile.cc')
-rw-r--r--apt-pkg/indexfile.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc
index 49665161d..bb2210bf6 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,63 @@ 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);
+
+ // 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_*)
+ char *need_full_langcode[] = { "pt","sv","zh","en", NULL };
+ for(char **s = need_full_langcode;*s != NULL; s++)
+ if(lang.find(*s) == 0)
+ return lang.substr(0,5);
+
+ if(lang.size() > 2)
+ return lang.substr(0,2);
+ else
+ return lang;
+ }
+ else
+ return Translation;
+}
+ /*}}}*/