- added gettext interface
authorMichael Andres <ma@suse.de>
Thu, 15 Dec 2005 00:07:44 +0000 (00:07 +0000)
committerMichael Andres <ma@suse.de>
Thu, 15 Dec 2005 00:07:44 +0000 (00:07 +0000)
- added class LanguageCode and CountryCode

zypp/CountryCode.cc [new file with mode: 0644]
zypp/CountryCode.h [new file with mode: 0644]
zypp/LanguageCode.cc [new file with mode: 0644]
zypp/LanguageCode.h [new file with mode: 0644]
zypp/Makefile.am
zypp/base/Gettext.cc [new file with mode: 0644]
zypp/base/Gettext.h [new file with mode: 0644]
zypp/base/Makefile.am
zypp/media/ProxyInfo.h

diff --git a/zypp/CountryCode.cc b/zypp/CountryCode.cc
new file mode 100644 (file)
index 0000000..1bf310b
--- /dev/null
@@ -0,0 +1,467 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/CountryCode.cc
+ *
+*/
+#include <iostream>
+#include <map>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
+
+#include "zypp/CountryCode.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  namespace
+  { /////////////////////////////////////////////////////////////////
+
+    typedef std::map<std::string,std::string> CodeMap;
+    typedef CodeMap::const_iterator Index;
+
+    // CodeMap[code] = untranslated country name
+    // Translation is done in name().
+    CodeMap _iso3166_CodeMap;
+    CodeMap _others_CodeMap;
+
+    void setDefaultCodeMaps( CodeMap & iso3166,
+                             CodeMap & others );
+
+    /** Assert code maps are initialized. */
+    void assertInitCodemaps()
+    {
+      if ( _others_CodeMap.empty() )
+        setDefaultCodeMaps( _iso3166_CodeMap,
+                            _others_CodeMap );
+    }
+
+    /** Return index of \a code_r, if it's in the code maps. */
+    Index lookupCode( const std::string & code_r )
+    {
+      assertInitCodemaps();
+      switch ( code_r.size() )
+        {
+        case 2:
+          {
+            Index it = _iso3166_CodeMap.find( code_r );
+            if ( it != _iso3166_CodeMap.end() )
+              return it;
+          }
+          break;
+        }
+      // not found: check _others_CodeMap
+      // !!! not found at all returns _others_CodeMap.end()
+      return _others_CodeMap.find( code_r );
+    }
+
+    /** Assert \a code_r is in the code maps and return it's index.
+     * That's what CountryCode::Impl calls.
+    */
+    Index getIndex( const std::string & code_r )
+    {
+      Index it = lookupCode( code_r );
+      if ( it != _others_CodeMap.end() )
+        return it;
+
+      // not found: Remember a new code
+      CodeMap::value_type nval( code_r, std::string() );
+
+      if ( code_r.size() != 2 )
+        WAR << "Malformed CountryCode '" << code_r << "' (expect 2-letter)" << endl;
+
+      std::string lcode( str::toUpper( code_r ) );
+      if ( lcode != code_r )
+        {
+          WAR << "Malformed CountryCode '" << code_r << "' (not upper case)" << endl;
+          // but maybe we're lucky with the upper case code
+          // and find a country name.
+          it = lookupCode( lcode );
+          if ( it != _others_CodeMap.end() )
+            nval.second = it->second;
+        }
+
+      MIL << "Remember CountryCode '" << code_r << "': '" << nval.second << "'" << endl;
+      return _others_CodeMap.insert( nval ).first;
+    }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace
+  ///////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : CountryCode::Impl
+  //
+  /** CountryCode implementation.
+   * \note CodeMaps contain the untranslated country names.
+   * Translation is done in \ref name.
+  */
+  struct CountryCode::Impl
+  {
+    Impl()
+    : _index( getIndex( std::string() ) )
+    {}
+
+    Impl( const std::string & code_r )
+    : _index( getIndex( code_r ) )
+    {}
+
+    std::string code() const
+    { return _index->first; }
+
+    std::string name() const {
+      if ( _index->second.empty() )
+        {
+          std::string ret( _("Unknown country: ") );
+          ret += "'";
+          ret += _index->first;
+          ret += "'";
+          return ret;
+        }
+      return _( _index->second.c_str() );
+    }
+
+  private:
+    /** index into code map. */
+    Index _index;
+
+  public:
+    /** Offer default Impl. */
+    static shared_ptr<Impl> nullimpl()
+    { if ( ! _nullimpl ) _nullimpl.reset( new Impl ); return _nullimpl; }
+
+  private:
+    /** Default Impl. */
+    static shared_ptr<Impl> _nullimpl;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  shared_ptr<CountryCode::Impl> CountryCode::Impl::_nullimpl;
+
+  ///////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : CountryCode
+  //
+  ///////////////////////////////////////////////////////////////////
+
+  const CountryCode CountryCode::noCode;
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : CountryCode::CountryCode
+  //   METHOD TYPE : Ctor
+  //
+  CountryCode::CountryCode()
+  : _pimpl( Impl::nullimpl() )
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : CountryCode::CountryCode
+  //   METHOD TYPE : Ctor
+  //
+  CountryCode::CountryCode( const std::string & code_r )
+  : _pimpl( new Impl( code_r ) )
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : CountryCode::~CountryCode
+  //   METHOD TYPE : Dtor
+  //
+  CountryCode::~CountryCode()
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : CountryCode::code
+  //   METHOD TYPE : std::string
+  //
+  std::string CountryCode::code() const
+  { return _pimpl->code(); }
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : CountryCode::name
+  //   METHOD TYPE : std::string
+  //
+  std::string CountryCode::name() const
+  { return _pimpl->name(); }
+
+  ///////////////////////////////////////////////////////////////////
+  namespace
+  { /////////////////////////////////////////////////////////////////
+
+    /** Initialize the code maps.
+     * http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
+    */
+    void setDefaultCodeMaps( CodeMap & iso3166,
+                             CodeMap & others )
+    {
+      // Defined CountryCode constants
+      others[""]        = N_( "noCode" );
+
+      iso3166["AD"] = N_( "Andorra" );                                 // :AND:020:
+      iso3166["AE"] = N_( "United Arab Emirates" );            // :ARE:784:
+      iso3166["AF"] = N_( "Afghanistan" );                     // :AFG:004:
+      iso3166["AG"] = N_( "Antigua and Barbuda" );             // :ATG:028:
+      iso3166["AI"] = N_( "Anguilla" );                        // :AIA:660:
+      iso3166["AL"] = N_( "Albania" );                                 // :ALB:008:
+      iso3166["AM"] = N_( "Armenia" );                                 // :ARM:051:
+      iso3166["AN"] = N_( "Netherlands Antilles" );            // :ANT:530:
+      iso3166["AO"] = N_( "Angola" );                          // :AGO:024:
+      iso3166["AQ"] = N_( "Antarctica" );                      // :ATA:010:
+      iso3166["AR"] = N_( "Argentina" );                       // :ARG:032:
+      iso3166["AS"] = N_( "American Samoa" );                  // :ASM:016:
+      iso3166["AT"] = N_( "Austria" );                                 // :AUT:040:
+      iso3166["AU"] = N_( "Australia" );                       // :AUS:036:
+      iso3166["AW"] = N_( "Aruba" );                           // :ABW:533:
+      iso3166["AX"] = N_( "Aland Islands" );                   // :ALA:248:
+      iso3166["AZ"] = N_( "Azerbaijan" );                      // :AZE:031:
+      iso3166["BA"] = N_( "Bosnia and Herzegovina" );          // :BIH:070:
+      iso3166["BB"] = N_( "Barbados" );                        // :BRB:052:
+      iso3166["BD"] = N_( "Bangladesh" );                      // :BGD:050:
+      iso3166["BE"] = N_( "Belgium" );                                 // :BEL:056:
+      iso3166["BF"] = N_( "Burkina Faso" );                    // :BFA:854:
+      iso3166["BG"] = N_( "Bulgaria" );                        // :BGR:100:
+      iso3166["BH"] = N_( "Bahrain" );                                 // :BHR:048:
+      iso3166["BI"] = N_( "Burundi" );                                 // :BDI:108:
+      iso3166["BJ"] = N_( "Benin" );                           // :BEN:204:
+      iso3166["BM"] = N_( "Bermuda" );                                 // :BMU:060:
+      iso3166["BN"] = N_( "Brunei Darussalam" );               // :BRN:096:
+      iso3166["BO"] = N_( "Bolivia" );                                 // :BOL:068:
+      iso3166["BR"] = N_( "Brazil" );                          // :BRA:076:
+      iso3166["BS"] = N_( "Bahamas" );                                 // :BHS:044:
+      iso3166["BT"] = N_( "Bhutan" );                          // :BTN:064:
+      iso3166["BV"] = N_( "Bouvet Island" );                   // :BVT:074:
+      iso3166["BW"] = N_( "Botswana" );                        // :BWA:072:
+      iso3166["BY"] = N_( "Belarus" );                                 // :BLR:112:
+      iso3166["BZ"] = N_( "Belize" );                          // :BLZ:084:
+      iso3166["CA"] = N_( "Canada" );                          // :CAN:124:
+      iso3166["CC"] = N_( "Cocos (Keeling) Islands" );                 // :CCK:166:
+      iso3166["CD"] = N_( "Congo" );                           // :COD:180:
+      iso3166["CF"] = N_( "Centruual African Republic" );      // :CAF:140:
+      iso3166["CG"] = N_( "Congo" );                           // :COG:178:
+      iso3166["CH"] = N_( "Switzerland" );                     // :CHE:756:
+      iso3166["CI"] = N_( "Cote D'Ivoire" );                   // :CIV:384:
+      iso3166["CK"] = N_( "Cook Islands" );                    // :COK:184:
+      iso3166["CL"] = N_( "Chile" );                           // :CHL:152:
+      iso3166["CM"] = N_( "Cameroon" );                        // :CMR:120:
+      iso3166["CN"] = N_( "China" );                           // :CHN:156:
+      iso3166["CO"] = N_( "Colombia" );                        // :COL:170:
+      iso3166["CR"] = N_( "Costa Rica" );                      // :CRI:188:
+      iso3166["CS"] = N_( "Serbia and Montenegro" );           // :SCG:891:
+      iso3166["CU"] = N_( "Cuba" );                            // :CUB:192:
+      iso3166["CV"] = N_( "Cape Verde" );                      // :CPV:132:
+      iso3166["CX"] = N_( "Christmas Island" );                // :CXR:162:
+      iso3166["CY"] = N_( "Cyprus" );                          // :CYP:196:
+      iso3166["CZ"] = N_( "Czech Republic" );                  // :CZE:203:
+      iso3166["DE"] = N_( "Germany" );                                 // :DEU:276:
+      iso3166["DJ"] = N_( "Djibouti" );                        // :DJI:262:
+      iso3166["DK"] = N_( "Denmark" );                                 // :DNK:208:
+      iso3166["DM"] = N_( "Dominica" );                        // :DMA:212:
+      iso3166["DO"] = N_( "Dominican Republic" );              // :DOM:214:
+      iso3166["DZ"] = N_( "Algeria" );                                 // :DZA:012:
+      iso3166["EC"] = N_( "Ecuador" );                                 // :ECU:218:
+      iso3166["EE"] = N_( "Estonia" );                                 // :EST:233:
+      iso3166["EG"] = N_( "Egypt" );                           // :EGY:818:
+      iso3166["EH"] = N_( "Western Sahara" );                  // :ESH:732:
+      iso3166["ER"] = N_( "Eritrea" );                                 // :ERI:232:
+      iso3166["ES"] = N_( "Spain" );                           // :ESP:724:
+      iso3166["ET"] = N_( "Ethiopia" );                        // :ETH:231:
+      iso3166["FI"] = N_( "Finland" );                                 // :FIN:246:
+      iso3166["FJ"] = N_( "Fiji" );                            // :FJI:242:
+      iso3166["FK"] = N_( "Falkland Islands (Malvinas)" );     // :FLK:238:
+      iso3166["FM"] = N_( "Federated States of Micronesia" );  // :FSM:583:
+      iso3166["FO"] = N_( "Faroe Islands" );                   // :FRO:234:
+      iso3166["FR"] = N_( "France" );                          // :FRA:250:
+      iso3166["FX"] = N_( "Metropolitan France" );             // :FXX:249:
+      iso3166["GA"] = N_( "Gabon" );                           // :GAB:266:
+      iso3166["GB"] = N_( "United Kingdom" );                  // :GBR:826:
+      iso3166["GD"] = N_( "Grenada" );                                 // :GRD:308:
+      iso3166["GE"] = N_( "Georgia" );                                 // :GEO:268:
+      iso3166["GF"] = N_( "French Guiana" );                   // :GUF:254:
+      iso3166["GH"] = N_( "Ghana" );                           // :GHA:288:
+      iso3166["GI"] = N_( "Gibraltar" );                       // :GIB:292:
+      iso3166["GL"] = N_( "Greenland" );                       // :GRL:304:
+      iso3166["GM"] = N_( "Gambia" );                          // :GMB:270:
+      iso3166["GN"] = N_( "Guinea" );                          // :GIN:324:
+      iso3166["GP"] = N_( "Guadeloupe" );                      // :GLP:312:
+      iso3166["GQ"] = N_( "Equatorial Guinea" );               // :GNQ:226:
+      iso3166["GR"] = N_( "Greece" );                          // :GRC:300:
+      iso3166["GS"] = N_( "South Georgia and the South Sandwich Islands" );    // :SGS:239:
+      iso3166["GT"] = N_( "Guatemala" );                       // :GTM:320:
+      iso3166["GU"] = N_( "Guam" );                            // :GUM:316:
+      iso3166["GW"] = N_( "Guinea-Bissau" );                   // :GNB:624:
+      iso3166["GY"] = N_( "Guyana" );                          // :GUY:328:
+      iso3166["HK"] = N_( "Hong Kong" );                       // :HKG:344:
+      iso3166["HM"] = N_( "Heard Island and McDonald Islands" ); // :HMD:334:
+      iso3166["HN"] = N_( "Honduras" );                        // :HND:340:
+      iso3166["HR"] = N_( "Croatia" );                                 // :HRV:191:
+      iso3166["HT"] = N_( "Haiti" );                           // :HTI:332:
+      iso3166["HU"] = N_( "Hungary" );                                 // :HUN:348:
+      iso3166["ID"] = N_( "Indonesia" );                       // :IDN:360:
+      iso3166["IE"] = N_( "Ireland" );                                 // :IRL:372:
+      iso3166["IL"] = N_( "Israel" );                          // :ISR:376:
+      iso3166["IN"] = N_( "India" );                           // :IND:356:
+      iso3166["IO"] = N_( "British Indian Ocean Territory" );  // :IOT:086:
+      iso3166["IQ"] = N_( "Iraq" );                            // :IRQ:368:
+      iso3166["IR"] = N_( "Iran" );                            // :IRN:364:
+      iso3166["IS"] = N_( "Iceland" );                                 // :ISL:352:
+      iso3166["IT"] = N_( "Italy" );                           // :ITA:380:
+      iso3166["JM"] = N_( "Jamaica" );                                 // :JAM:388:
+      iso3166["JO"] = N_( "Jordan" );                          // :JOR:400:
+      iso3166["JP"] = N_( "Japan" );                           // :JPN:392:
+      iso3166["KE"] = N_( "Kenya" );                           // :KEN:404:
+      iso3166["KG"] = N_( "Kyrgyzstan" );                      // :KGZ:417:
+      iso3166["KH"] = N_( "Cambodia" );                        // :KHM:116:
+      iso3166["KI"] = N_( "Kiribati" );                        // :KIR:296:
+      iso3166["KM"] = N_( "Comoros" );                                 // :COM:174:
+      iso3166["KN"] = N_( "Saint Kitts and Nevis" );           // :KNA:659:
+      iso3166["KP"] = N_( "North Korea" );                     // :PRK:408:
+      iso3166["KR"] = N_( "South Korea" );                     // :KOR:410:
+      iso3166["KW"] = N_( "Kuwait" );                          // :KWT:414:
+      iso3166["KY"] = N_( "Cayman Islands" );                  // :CYM:136:
+      iso3166["KZ"] = N_( "Kazakhstan" );                      // :KAZ:398:
+      iso3166["LA"] = N_( "Lao People's Democratic Republic" );        // :LAO:418:
+      iso3166["LB"] = N_( "Lebanon" );                                 // :LBN:422:
+      iso3166["LC"] = N_( "Saint Lucia" );                     // :LCA:662:
+      iso3166["LI"] = N_( "Liechtenstein" );                   // :LIE:438:
+      iso3166["LK"] = N_( "Sri Lanka" );                       // :LKA:144:
+      iso3166["LR"] = N_( "Liberia" );                                 // :LBR:430:
+      iso3166["LS"] = N_( "Lesotho" );                                 // :LSO:426:
+      iso3166["LT"] = N_( "Lithuania" );                       // :LTU:440:
+      iso3166["LU"] = N_( "Luxembourg" );                      // :LUX:442:
+      iso3166["LV"] = N_( "Latvia" );                          // :LVA:428:
+      iso3166["LY"] = N_( "Libya" );                           // :LBY:434:
+      iso3166["MA"] = N_( "Morocco" );                                 // :MAR:504:
+      iso3166["MC"] = N_( "Monaco" );                          // :MCO:492:
+      iso3166["MD"] = N_( "Moldova" );                                 // :MDA:498:
+      iso3166["MG"] = N_( "Madagascar" );                      // :MDG:450:
+      iso3166["MH"] = N_( "Marshall Islands" );                // :MHL:584:
+      iso3166["MK"] = N_( "Macedonia" );                       // :MKD:807:
+      iso3166["ML"] = N_( "Mali" );                            // :MLI:466:
+      iso3166["MM"] = N_( "Myanmar" );                                 // :MMR:104:
+      iso3166["MN"] = N_( "Mongolia" );                        // :MNG:496:
+      iso3166["MO"] = N_( "Macao" );                           // :MAC:446:
+      iso3166["MP"] = N_( "Northern Mariana Islands" );        // :MNP:580:
+      iso3166["MQ"] = N_( "Martinique" );                      // :MTQ:474:
+      iso3166["MR"] = N_( "Mauritania" );                      // :MRT:478:
+      iso3166["MS"] = N_( "Montserrat" );                      // :MSR:500:
+      iso3166["MT"] = N_( "Malta" );                           // :MLT:470:
+      iso3166["MU"] = N_( "Mauritius" );                       // :MUS:480:
+      iso3166["MV"] = N_( "Maldives" );                        // :MDV:462:
+      iso3166["MW"] = N_( "Malawi" );                          // :MWI:454:
+      iso3166["MX"] = N_( "Mexico" );                          // :MEX:484:
+      iso3166["MY"] = N_( "Malaysia" );                        // :MYS:458:
+      iso3166["MZ"] = N_( "Mozambique" );                      // :MOZ:508:
+      iso3166["NA"] = N_( "Namibia" );                                 // :NAM:516:
+      iso3166["NC"] = N_( "New Caledonia" );                   // :NCL:540:
+      iso3166["NE"] = N_( "Niger" );                           // :NER:562:
+      iso3166["NF"] = N_( "Norfolk Island" );                  // :NFK:574:
+      iso3166["NG"] = N_( "Nigeria" );                                 // :NGA:566:
+      iso3166["NI"] = N_( "Nicaragua" );                       // :NIC:558:
+      iso3166["NL"] = N_( "Netherlands" );                     // :NLD:528:
+      iso3166["NO"] = N_( "Norway" );                          // :NOR:578:
+      iso3166["NP"] = N_( "Nepal" );                           // :NPL:524:
+      iso3166["NR"] = N_( "Nauru" );                           // :NRU:520:
+      iso3166["NU"] = N_( "Niue" );                            // :NIU:570:
+      iso3166["NZ"] = N_( "New Zealand" );                     // :NZL:554:
+      iso3166["OM"] = N_( "Oman" );                            // :OMN:512:
+      iso3166["PA"] = N_( "Panama" );                          // :PAN:591:
+      iso3166["PE"] = N_( "Peru" );                            // :PER:604:
+      iso3166["PF"] = N_( "French Polynesia" );                // :PYF:258:
+      iso3166["PG"] = N_( "Papua New Guinea" );                // :PNG:598:
+      iso3166["PH"] = N_( "Philippines" );                     // :PHL:608:
+      iso3166["PK"] = N_( "Pakistan" );                        // :PAK:586:
+      iso3166["PL"] = N_( "Poland" );                          // :POL:616:
+      iso3166["PM"] = N_( "Saint Pierre and Miquelon" );       // :SPM:666:
+      iso3166["PN"] = N_( "Pitcairn" );                        // :PCN:612:
+      iso3166["PR"] = N_( "Puerto Rico" );                     // :PRI:630:
+      iso3166["PS"] = N_( "Palestinian Territory" );           // :PSE:275:
+      iso3166["PT"] = N_( "Portugal" );                        // :PRT:620:
+      iso3166["PW"] = N_( "Palau" );                           // :PLW:585:
+      iso3166["PY"] = N_( "Paraguay" );                        // :PRY:600:
+      iso3166["QA"] = N_( "Qatar" );                           // :QAT:634:
+      iso3166["RE"] = N_( "Reunion" );                                 // :REU:638:
+      iso3166["RO"] = N_( "Romania" );                                 // :ROU:642:
+      iso3166["RU"] = N_( "Russian Federation" );              // :RUS:643:
+      iso3166["RW"] = N_( "Rwanda" );                          // :RWA:646:
+      iso3166["SA"] = N_( "Saudi Arabia" );                    // :SAU:682:
+      iso3166["SB"] = N_( "Solomon Islands" );                         // :SLB:090:
+      iso3166["SC"] = N_( "Seychelles" );                      // :SYC:690:
+      iso3166["SD"] = N_( "Sudan" );                           // :SDN:736:
+      iso3166["SE"] = N_( "Sweden" );                          // :SWE:752:
+      iso3166["SG"] = N_( "Singapore" );                       // :SGP:702:
+      iso3166["SH"] = N_( "Saint Helena" );                    // :SHN:654:
+      iso3166["SI"] = N_( "Slovenia" );                        // :SVN:705:
+      iso3166["SJ"] = N_( "Svalbard and Jan Mayen" );          // :SJM:744:
+      iso3166["SK"] = N_( "Slovakia" );                        // :SVK:703:
+      iso3166["SL"] = N_( "Sierra Leone" );                    // :SLE:694:
+      iso3166["SM"] = N_( "San Marino" );                      // :SMR:674:
+      iso3166["SN"] = N_( "Senegal" );                                 // :SEN:686:
+      iso3166["SO"] = N_( "Somalia" );                                 // :SOM:706:
+      iso3166["SR"] = N_( "Suriname" );                        // :SUR:740:
+      iso3166["ST"] = N_( "Sao Tome and Principe" );           // :STP:678:
+      iso3166["SV"] = N_( "El Salvador" );                     // :SLV:222:
+      iso3166["SY"] = N_( "Syria" );                           // :SYR:760:
+      iso3166["SZ"] = N_( "Swaziland" );                       // :SWZ:748:
+      iso3166["TC"] = N_( "Turks and Caicos Islands" );        // :TCA:796:
+      iso3166["TD"] = N_( "Chad" );                            // :TCD:148:
+      iso3166["TF"] = N_( "French Southern Territories" );     // :ATF:260:
+      iso3166["TG"] = N_( "Togo" );                            // :TGO:768:
+      iso3166["TH"] = N_( "Thailand" );                        // :THA:764:
+      iso3166["TJ"] = N_( "Tajikistan" );                      // :TJK:762:
+      iso3166["TK"] = N_( "Tokelau" );                                 // :TKL:772:
+      iso3166["TM"] = N_( "Turkmenistan" );                    // :TKM:795:
+      iso3166["TN"] = N_( "Tunisia" );                                 // :TUN:788:
+      iso3166["TO"] = N_( "Tonga" );                           // :TON:776:
+      iso3166["TL"] = N_( "East Timor" );                      // :TLS:626:
+      iso3166["TR"] = N_( "Turkey" );                          // :TUR:792:
+      iso3166["TT"] = N_( "Trinidad and Tobago" );             // :TTO:780:
+      iso3166["TV"] = N_( "Tuvalu" );                          // :TUV:798:
+      iso3166["TW"] = N_( "Taiwan" );                          // :TWN:158:
+      iso3166["TZ"] = N_( "Tanzania" );                        // :TZA:834:
+      iso3166["UA"] = N_( "Ukraine" );                                 // :UKR:804:
+      iso3166["UG"] = N_( "Uganda" );                          // :UGA:800:
+      iso3166["UM"] = N_( "United States Minor Outlying Islands" );    // :UMI:581:
+      iso3166["US"] = N_( "United States" );                   // :USA:840:
+      iso3166["UY"] = N_( "Uruguay" );                                 // :URY:858:
+      iso3166["UZ"] = N_( "Uzbekistan" );                      // :UZB:860:
+      iso3166["VA"] = N_( "Holy See (Vatican City State)" );   // :VAT:336:
+      iso3166["VC"] = N_( "Saint Vincent and the Grenadines" ); // :VCT:670:
+      iso3166["VE"] = N_( "Venezuela" );                       // :VEN:862:
+      iso3166["VG"] = N_( "British Virgin Islands" );          // :VGB:092:
+      iso3166["VI"] = N_( "Virgin Islands, U.S." );            // :VIR:850:
+      iso3166["VN"] = N_( "Vietnam" );                                 // :VNM:704:
+      iso3166["VU"] = N_( "Vanuatu" );                                 // :VUT:548:
+      iso3166["WF"] = N_( "Wallis and Futuna" );               // :WLF:876:
+      iso3166["WS"] = N_( "Samoa" );                           // :WSM:882:
+      iso3166["YE"] = N_( "Yemen" );                           // :YEM:887:
+      iso3166["YT"] = N_( "Mayotte" );                                 // :MYT:175:
+      iso3166["ZA"] = N_( "South Africa" );                    // :ZAF:710:
+      iso3166["ZM"] = N_( "Zambia" );                          // :ZMB:894:
+      iso3166["ZW"] = N_( "Zimbabwe" );                        // :ZWE:716:
+    }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace
+  ///////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/CountryCode.h b/zypp/CountryCode.h
new file mode 100644 (file)
index 0000000..abaa7e0
--- /dev/null
@@ -0,0 +1,120 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/CountryCode.h
+ *
+*/
+#ifndef ZYPP_COUNTRYCODE_H
+#define ZYPP_COUNTRYCODE_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/base/PtrTypes.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : CountryCode
+  //
+  /** Country codes (iso3166-1-alpha-2).
+   *
+   * In fact the class will not prevent to use a non iso country code.
+   * Just a warning will appear in the log.
+  */
+  class CountryCode
+  {
+    friend std::ostream & operator<<( std::ostream & str, const CountryCode & obj );
+
+  public:
+    /** Implementation  */
+    class Impl;
+
+  public:
+    /** Default ctor */
+    CountryCode();
+
+    /** Ctor taking a string. */
+    explicit
+    CountryCode( const std::string & code_r );
+
+    /** Dtor */
+    ~CountryCode();
+
+  public:
+
+    /** \name CountryCode constants. */
+    //@{
+    /** No or empty code. */
+    static const CountryCode noCode;
+    //@}
+
+  public:
+    /** Return the country code. */
+    std::string code() const;
+
+    /** Return the country name; if not available the country code. */
+    std::string name() const;
+
+  private:
+    /** Pointer to implementation */
+    RW_pointer<Impl> _pimpl;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /** \relates CountryCode Stream output */
+  inline std::ostream & operator<<( std::ostream & str, const CountryCode & obj )
+  { return str << obj.code(); }
+
+  /** Comparison based on string value. */
+  //@{
+  /** \relates CountryCode */
+  inline bool operator==( const CountryCode & lhs, const CountryCode & rhs ) {
+    return( lhs.code() == rhs.code() );
+  }
+  /** \relates CountryCode */
+  inline bool operator==( const std::string & lhs, const CountryCode & rhs ) {
+    return( lhs == rhs.code() );
+  }
+  /** \relates CountryCode */
+  inline bool operator==( const CountryCode & lhs, const std::string & rhs ) {
+    return( lhs.code() == rhs );
+  }
+
+  /** \relates CountryCode */
+  inline bool operator!=( const CountryCode & lhs, const CountryCode & rhs ) {
+    return( ! operator==( lhs, rhs ) );
+  }
+  /** \relates CountryCode */
+  inline bool operator!=( const std::string & lhs, const CountryCode & rhs ) {
+    return( ! operator==( lhs, rhs ) );
+  }
+  /** \relates CountryCode */
+  inline bool operator!=( const CountryCode & lhs, const std::string & rhs ) {
+    return( ! operator==( lhs, rhs ) );
+  }
+  //@}
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+namespace std
+{ /////////////////////////////////////////////////////////////////
+  /** \relates CountryCode Default order for std::container based on code string value.*/
+  template<>
+    inline bool less<zypp::CountryCode>::operator()( const zypp::CountryCode & lhs, const zypp::CountryCode & rhs ) const
+    { return lhs.code() < rhs.code(); }
+  /////////////////////////////////////////////////////////////////
+} // namespace std
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_COUNTRYCODE_H
diff --git a/zypp/LanguageCode.cc b/zypp/LanguageCode.cc
new file mode 100644 (file)
index 0000000..4dffb1e
--- /dev/null
@@ -0,0 +1,1186 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/LanguageCode.cc
+ *
+*/
+#include <iostream>
+#include <map>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
+
+#include "zypp/LanguageCode.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  namespace
+  { /////////////////////////////////////////////////////////////////
+
+    typedef std::map<std::string,std::string> CodeMap;
+    typedef CodeMap::const_iterator Index;
+
+    // CodeMap[code] = untranslated language name
+    // Translation is done in name().
+    CodeMap _iso639_1_CodeMap;
+    CodeMap _iso639_2_CodeMap;
+    CodeMap _others_CodeMap;
+
+    void setDefaultCodeMaps( CodeMap & iso639_1,
+                             CodeMap & iso639_2,
+                             CodeMap & others );
+
+    /** Assert code maps are initialized. */
+    void assertInitCodemaps()
+    {
+      if ( _others_CodeMap.empty() )
+        setDefaultCodeMaps( _iso639_1_CodeMap,
+                            _iso639_2_CodeMap,
+                            _others_CodeMap );
+    }
+
+    /** Return index of \a code_r, if it's in the code maps. */
+    Index lookupCode( const std::string & code_r )
+    {
+      assertInitCodemaps();
+      switch ( code_r.size() )
+        {
+        case 2:
+          {
+            Index it = _iso639_1_CodeMap.find( code_r );
+            if ( it != _iso639_1_CodeMap.end() )
+              return it;
+          }
+          break;
+
+        case 3:
+          {
+            Index it = _iso639_2_CodeMap.find( code_r );
+            if ( it != _iso639_2_CodeMap.end() )
+              return it;
+          }
+          break;
+        }
+      // not found: check _others_CodeMap
+      // !!! not found at all returns _others_CodeMap.end()
+      return _others_CodeMap.find( code_r );
+    }
+
+    /** Assert \a code_r is in the code maps and return it's index.
+     * That's what LanguageCode::Impl calls.
+    */
+    Index getIndex( const std::string & code_r )
+    {
+      Index it = lookupCode( code_r );
+      if ( it != _others_CodeMap.end() )
+        return it;
+
+      // not found: Remember a new code
+      CodeMap::value_type nval( code_r, std::string() );
+
+      if ( code_r.size() > 3 || code_r.size() < 2 )
+        WAR << "Malformed LanguageCode '" << code_r << "' (expect 2 or 3-letter)" << endl;
+
+      std::string lcode( str::toLower( code_r ) );
+      if ( lcode != code_r )
+        {
+          WAR << "Malformed LanguageCode '" << code_r << "' (not lower case)" << endl;
+          // but maybe we're lucky with the lower case code
+          // and find a language name.
+          it = lookupCode( lcode );
+          if ( it != _others_CodeMap.end() )
+            nval.second = it->second;
+        }
+
+      MIL << "Remember LanguageCode '" << code_r << "': '" << nval.second << "'" << endl;
+      return _others_CodeMap.insert( nval ).first;
+    }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace
+  ///////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : LanguageCode::Impl
+  //
+  /** LanguageCode implementation.
+   * \note CodeMaps contain the untranslated language names.
+   * Translation is done in \ref name.
+  */
+  struct LanguageCode::Impl
+  {
+    Impl()
+    : _index( getIndex( std::string() ) )
+    {}
+
+    Impl( const std::string & code_r )
+    : _index( getIndex( code_r ) )
+    {}
+
+    std::string code() const
+    { return _index->first; }
+
+    std::string name() const {
+      if ( _index->second.empty() )
+        {
+          std::string ret( _("Unknown language: ") );
+          ret += "'";
+          ret += _index->first;
+          ret += "'";
+          return ret;
+        }
+      return _( _index->second.c_str() );
+    }
+
+  private:
+    /** index into code map. */
+    Index _index;
+
+  public:
+    /** Offer default Impl. */
+    static shared_ptr<Impl> nullimpl()
+    { if ( ! _nullimpl ) _nullimpl.reset( new Impl ); return _nullimpl; }
+
+  private:
+    /** Default Impl. */
+    static shared_ptr<Impl> _nullimpl;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  shared_ptr<LanguageCode::Impl> LanguageCode::Impl::_nullimpl;
+
+  ///////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : LanguageCode
+  //
+  ///////////////////////////////////////////////////////////////////
+
+  const LanguageCode LanguageCode::noCode;
+  const LanguageCode LanguageCode::useDefault( "default" );
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : LanguageCode::LanguageCode
+  //   METHOD TYPE : Ctor
+  //
+  LanguageCode::LanguageCode()
+  : _pimpl( Impl::nullimpl() )
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : LanguageCode::LanguageCode
+  //   METHOD TYPE : Ctor
+  //
+  LanguageCode::LanguageCode( const std::string & code_r )
+  : _pimpl( new Impl( code_r ) )
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : LanguageCode::~LanguageCode
+  //   METHOD TYPE : Dtor
+  //
+  LanguageCode::~LanguageCode()
+  {}
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : LanguageCode::code
+  //   METHOD TYPE : std::string
+  //
+  std::string LanguageCode::code() const
+  { return _pimpl->code(); }
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : LanguageCode::name
+  //   METHOD TYPE : std::string
+  //
+  std::string LanguageCode::name() const
+  { return _pimpl->name(); }
+
+  ///////////////////////////////////////////////////////////////////
+  namespace
+  { /////////////////////////////////////////////////////////////////
+
+    /** Initialize the code maps.
+     * http://www.loc.gov/standards/iso639-2/ISO-639-2_values_8bits.txt
+    */
+    void setDefaultCodeMaps( CodeMap & iso639_1,
+                             CodeMap & iso639_2,
+                             CodeMap & others )
+    {
+      // Defined LanguageCode constants
+      others[""]        = N_( "noCode" );
+      others["default"] = N_( "Default" );
+
+      // language code: aar aa
+      iso639_2["aar"]                   = iso639_1["aa"] = N_( "Afar" );
+      // language code: abk ab
+      iso639_2["abk"]                   = iso639_1["ab"] = N_( "Abkhazian" );
+      // language code: ace
+      iso639_2["ace"]                                    = N_( "Achinese" );
+      // language code: ach
+      iso639_2["ach"]                                    = N_( "Acoli" );
+      // language code: ada
+      iso639_2["ada"]                                    = N_( "Adangme" );
+      // language code: ady
+      iso639_2["ady"]                                    = N_( "Adyghe" );
+      // language code: afa
+      iso639_2["afa"]                                    = N_( "Afro-Asiatic (Other)" );
+      // language code: afh
+      iso639_2["afh"]                                    = N_( "Afrihili" );
+      // language code: afr af
+      iso639_2["afr"]                   = iso639_1["af"] = N_( "Afrikaans" );
+      // language code: ain
+      iso639_2["ain"]                                    = N_( "Ainu" );
+      // language code: aka ak
+      iso639_2["aka"]                   = iso639_1["ak"] = N_( "Akan" );
+      // language code: akk
+      iso639_2["akk"]                                    = N_( "Akkadian" );
+      // language code: alb sqi sq
+      iso639_2["alb"] = iso639_2["sqi"] = iso639_1["sq"] = N_( "Albanian" );
+      // language code: ale
+      iso639_2["ale"]                                    = N_( "Aleut" );
+      // language code: alg
+      iso639_2["alg"]                                    = N_( "Algonquian languages" );
+      // language code: alt
+      iso639_2["alt"]                                    = N_( "Southern Altai" );
+      // language code: amh am
+      iso639_2["amh"]                   = iso639_1["am"] = N_( "Amharic" );
+      // language code: ang
+      iso639_2["ang"]                                    = N_( "English, Old (ca.450-1100)" );
+      // language code: apa
+      iso639_2["apa"]                                    = N_( "Apache languages" );
+      // language code: ara ar
+      iso639_2["ara"]                   = iso639_1["ar"] = N_( "Arabic" );
+      // language code: arc
+      iso639_2["arc"]                                    = N_( "Aramaic" );
+      // language code: arg an
+      iso639_2["arg"]                   = iso639_1["an"] = N_( "Aragonese" );
+      // language code: arm hye hy
+      iso639_2["arm"] = iso639_2["hye"] = iso639_1["hy"] = N_( "Armenian" );
+      // language code: arn
+      iso639_2["arn"]                                    = N_( "Araucanian" );
+      // language code: arp
+      iso639_2["arp"]                                    = N_( "Arapaho" );
+      // language code: art
+      iso639_2["art"]                                    = N_( "Artificial (Other)" );
+      // language code: arw
+      iso639_2["arw"]                                    = N_( "Arawak" );
+      // language code: asm as
+      iso639_2["asm"]                   = iso639_1["as"] = N_( "Assamese" );
+      // language code: ast
+      iso639_2["ast"]                                    = N_( "Asturian" );
+      // language code: ath
+      iso639_2["ath"]                                    = N_( "Athapascan languages" );
+      // language code: aus
+      iso639_2["aus"]                                    = N_( "Australian languages" );
+      // language code: ava av
+      iso639_2["ava"]                   = iso639_1["av"] = N_( "Avaric" );
+      // language code: ave ae
+      iso639_2["ave"]                   = iso639_1["ae"] = N_( "Avestan" );
+      // language code: awa
+      iso639_2["awa"]                                    = N_( "Awadhi" );
+      // language code: aym ay
+      iso639_2["aym"]                   = iso639_1["ay"] = N_( "Aymara" );
+      // language code: aze az
+      iso639_2["aze"]                   = iso639_1["az"] = N_( "Azerbaijani" );
+      // language code: bad
+      iso639_2["bad"]                                    = N_( "Banda" );
+      // language code: bai
+      iso639_2["bai"]                                    = N_( "Bamileke languages" );
+      // language code: bak ba
+      iso639_2["bak"]                   = iso639_1["ba"] = N_( "Bashkir" );
+      // language code: bal
+      iso639_2["bal"]                                    = N_( "Baluchi" );
+      // language code: bam bm
+      iso639_2["bam"]                   = iso639_1["bm"] = N_( "Bambara" );
+      // language code: ban
+      iso639_2["ban"]                                    = N_( "Balinese" );
+      // language code: baq eus eu
+      iso639_2["baq"] = iso639_2["eus"] = iso639_1["eu"] = N_( "Basque" );
+      // language code: bas
+      iso639_2["bas"]                                    = N_( "Basa" );
+      // language code: bat
+      iso639_2["bat"]                                    = N_( "Baltic (Other)" );
+      // language code: bej
+      iso639_2["bej"]                                    = N_( "Beja" );
+      // language code: bel be
+      iso639_2["bel"]                   = iso639_1["be"] = N_( "Belarusian" );
+      // language code: bem
+      iso639_2["bem"]                                    = N_( "Bemba" );
+      // language code: ben bn
+      iso639_2["ben"]                   = iso639_1["bn"] = N_( "Bengali" );
+      // language code: ber
+      iso639_2["ber"]                                    = N_( "Berber (Other)" );
+      // language code: bho
+      iso639_2["bho"]                                    = N_( "Bhojpuri" );
+      // language code: bih bh
+      iso639_2["bih"]                   = iso639_1["bh"] = N_( "Bihari" );
+      // language code: bik
+      iso639_2["bik"]                                    = N_( "Bikol" );
+      // language code: bin
+      iso639_2["bin"]                                    = N_( "Bini" );
+      // language code: bis bi
+      iso639_2["bis"]                   = iso639_1["bi"] = N_( "Bislama" );
+      // language code: bla
+      iso639_2["bla"]                                    = N_( "Siksika" );
+      // language code: bnt
+      iso639_2["bnt"]                                    = N_( "Bantu (Other)" );
+      // language code: bos bs
+      iso639_2["bos"]                   = iso639_1["bs"] = N_( "Bosnian" );
+      // language code: bra
+      iso639_2["bra"]                                    = N_( "Braj" );
+      // language code: bre br
+      iso639_2["bre"]                   = iso639_1["br"] = N_( "Breton" );
+      // language code: btk
+      iso639_2["btk"]                                    = N_( "Batak (Indonesia)" );
+      // language code: bua
+      iso639_2["bua"]                                    = N_( "Buriat" );
+      // language code: bug
+      iso639_2["bug"]                                    = N_( "Buginese" );
+      // language code: bul bg
+      iso639_2["bul"]                   = iso639_1["bg"] = N_( "Bulgarian" );
+      // language code: bur mya my
+      iso639_2["bur"] = iso639_2["mya"] = iso639_1["my"] = N_( "Burmese" );
+      // language code: byn
+      iso639_2["byn"]                                    = N_( "Blin" );
+      // language code: cad
+      iso639_2["cad"]                                    = N_( "Caddo" );
+      // language code: cai
+      iso639_2["cai"]                                    = N_( "Central American Indian (Other)" );
+      // language code: car
+      iso639_2["car"]                                    = N_( "Carib" );
+      // language code: cat ca
+      iso639_2["cat"]                   = iso639_1["ca"] = N_( "Catalan" );
+      // language code: cau
+      iso639_2["cau"]                                    = N_( "Caucasian (Other)" );
+      // language code: ceb
+      iso639_2["ceb"]                                    = N_( "Cebuano" );
+      // language code: cel
+      iso639_2["cel"]                                    = N_( "Celtic (Other)" );
+      // language code: cha ch
+      iso639_2["cha"]                   = iso639_1["ch"] = N_( "Chamorro" );
+      // language code: chb
+      iso639_2["chb"]                                    = N_( "Chibcha" );
+      // language code: che ce
+      iso639_2["che"]                   = iso639_1["ce"] = N_( "Chechen" );
+      // language code: chg
+      iso639_2["chg"]                                    = N_( "Chagatai" );
+      // language code: chi zho zh
+      iso639_2["chi"] = iso639_2["zho"] = iso639_1["zh"] = N_( "Chinese" );
+      // language code: chk
+      iso639_2["chk"]                                    = N_( "Chuukese" );
+      // language code: chm
+      iso639_2["chm"]                                    = N_( "Mari" );
+      // language code: chn
+      iso639_2["chn"]                                    = N_( "Chinook jargon" );
+      // language code: cho
+      iso639_2["cho"]                                    = N_( "Choctaw" );
+      // language code: chp
+      iso639_2["chp"]                                    = N_( "Chipewyan" );
+      // language code: chr
+      iso639_2["chr"]                                    = N_( "Cherokee" );
+      // language code: chu cu
+      iso639_2["chu"]                   = iso639_1["cu"] = N_( "Church Slavic" );
+      // language code: chv cv
+      iso639_2["chv"]                   = iso639_1["cv"] = N_( "Chuvash" );
+      // language code: chy
+      iso639_2["chy"]                                    = N_( "Cheyenne" );
+      // language code: cmc
+      iso639_2["cmc"]                                    = N_( "Chamic languages" );
+      // language code: cop
+      iso639_2["cop"]                                    = N_( "Coptic" );
+      // language code: cor kw
+      iso639_2["cor"]                   = iso639_1["kw"] = N_( "Cornish" );
+      // language code: cos co
+      iso639_2["cos"]                   = iso639_1["co"] = N_( "Corsican" );
+      // language code: cpe
+      iso639_2["cpe"]                                    = N_( "Creoles and pidgins, English based (Other)" );
+      // language code: cpf
+      iso639_2["cpf"]                                    = N_( "Creoles and pidgins, French-based (Other)" );
+      // language code: cpp
+      iso639_2["cpp"]                                    = N_( "Creoles and pidgins, Portuguese-based (Other)" );
+      // language code: cre cr
+      iso639_2["cre"]                   = iso639_1["cr"] = N_( "Cree" );
+      // language code: crh
+      iso639_2["crh"]                                    = N_( "Crimean Tatar" );
+      // language code: crp
+      iso639_2["crp"]                                    = N_( "Creoles and pidgins (Other)" );
+      // language code: csb
+      iso639_2["csb"]                                    = N_( "Kashubian" );
+      // language code: cus
+      iso639_2["cus"]                                    = N_( "Cushitic (Other)" );
+      // language code: cze ces cs
+      iso639_2["cze"] = iso639_2["ces"] = iso639_1["cs"] = N_( "Czech" );
+      // language code: dak
+      iso639_2["dak"]                                    = N_( "Dakota" );
+      // language code: dan da
+      iso639_2["dan"]                   = iso639_1["da"] = N_( "Danish" );
+      // language code: dar
+      iso639_2["dar"]                                    = N_( "Dargwa" );
+      // language code: day
+      iso639_2["day"]                                    = N_( "Dayak" );
+      // language code: del
+      iso639_2["del"]                                    = N_( "Delaware" );
+      // language code: den
+      iso639_2["den"]                                    = N_( "Slave (Athapascan)" );
+      // language code: dgr
+      iso639_2["dgr"]                                    = N_( "Dogrib" );
+      // language code: din
+      iso639_2["din"]                                    = N_( "Dinka" );
+      // language code: div dv
+      iso639_2["div"]                   = iso639_1["dv"] = N_( "Divehi" );
+      // language code: doi
+      iso639_2["doi"]                                    = N_( "Dogri" );
+      // language code: dra
+      iso639_2["dra"]                                    = N_( "Dravidian (Other)" );
+      // language code: dsb
+      iso639_2["dsb"]                                    = N_( "Lower Sorbian" );
+      // language code: dua
+      iso639_2["dua"]                                    = N_( "Duala" );
+      // language code: dum
+      iso639_2["dum"]                                    = N_( "Dutch, Middle (ca.1050-1350)" );
+      // language code: dut nld nl
+      iso639_2["dut"] = iso639_2["nld"] = iso639_1["nl"] = N_( "Dutch" );
+      // language code: dyu
+      iso639_2["dyu"]                                    = N_( "Dyula" );
+      // language code: dzo dz
+      iso639_2["dzo"]                   = iso639_1["dz"] = N_( "Dzongkha" );
+      // language code: efi
+      iso639_2["efi"]                                    = N_( "Efik" );
+      // language code: egy
+      iso639_2["egy"]                                    = N_( "Egyptian (Ancient)" );
+      // language code: eka
+      iso639_2["eka"]                                    = N_( "Ekajuk" );
+      // language code: elx
+      iso639_2["elx"]                                    = N_( "Elamite" );
+      // language code: eng en
+      iso639_2["eng"]                   = iso639_1["en"] = N_( "English" );
+      // language code: enm
+      iso639_2["enm"]                                    = N_( "English, Middle (1100-1500)" );
+      // language code: epo eo
+      iso639_2["epo"]                   = iso639_1["eo"] = N_( "Esperanto" );
+      // language code: est et
+      iso639_2["est"]                   = iso639_1["et"] = N_( "Estonian" );
+      // language code: ewe ee
+      iso639_2["ewe"]                   = iso639_1["ee"] = N_( "Ewe" );
+      // language code: ewo
+      iso639_2["ewo"]                                    = N_( "Ewondo" );
+      // language code: fan
+      iso639_2["fan"]                                    = N_( "Fang" );
+      // language code: fao fo
+      iso639_2["fao"]                   = iso639_1["fo"] = N_( "Faroese" );
+      // language code: fat
+      iso639_2["fat"]                                    = N_( "Fanti" );
+      // language code: fij fj
+      iso639_2["fij"]                   = iso639_1["fj"] = N_( "Fijian" );
+      // language code: fil
+      iso639_2["fil"]                                    = N_( "Filipino" );
+      // language code: fin fi
+      iso639_2["fin"]                   = iso639_1["fi"] = N_( "Finnish" );
+      // language code: fiu
+      iso639_2["fiu"]                                    = N_( "Finno-Ugrian (Other)" );
+      // language code: fon
+      iso639_2["fon"]                                    = N_( "Fon" );
+      // language code: fre fra fr
+      iso639_2["fre"] = iso639_2["fra"] = iso639_1["fr"] = N_( "French" );
+      // language code: frm
+      iso639_2["frm"]                                    = N_( "French, Middle (ca.1400-1600)" );
+      // language code: fro
+      iso639_2["fro"]                                    = N_( "French, Old (842-ca.1400)" );
+      // language code: fry fy
+      iso639_2["fry"]                   = iso639_1["fy"] = N_( "Frisian" );
+      // language code: ful ff
+      iso639_2["ful"]                   = iso639_1["ff"] = N_( "Fulah" );
+      // language code: fur
+      iso639_2["fur"]                                    = N_( "Friulian" );
+      // language code: gaa
+      iso639_2["gaa"]                                    = N_( "Ga" );
+      // language code: gay
+      iso639_2["gay"]                                    = N_( "Gayo" );
+      // language code: gba
+      iso639_2["gba"]                                    = N_( "Gbaya" );
+      // language code: gem
+      iso639_2["gem"]                                    = N_( "Germanic (Other)" );
+      // language code: geo kat ka
+      iso639_2["geo"] = iso639_2["kat"] = iso639_1["ka"] = N_( "Georgian" );
+      // language code: ger deu de
+      iso639_2["ger"] = iso639_2["deu"] = iso639_1["de"] = N_( "German" );
+      // language code: gez
+      iso639_2["gez"]                                    = N_( "Geez" );
+      // language code: gil
+      iso639_2["gil"]                                    = N_( "Gilbertese" );
+      // language code: gla gd
+      iso639_2["gla"]                   = iso639_1["gd"] = N_( "Gaelic" );
+      // language code: gle ga
+      iso639_2["gle"]                   = iso639_1["ga"] = N_( "Irish" );
+      // language code: glg gl
+      iso639_2["glg"]                   = iso639_1["gl"] = N_( "Galician" );
+      // language code: glv gv
+      iso639_2["glv"]                   = iso639_1["gv"] = N_( "Manx" );
+      // language code: gmh
+      iso639_2["gmh"]                                    = N_( "German, Middle High (ca.1050-1500)" );
+      // language code: goh
+      iso639_2["goh"]                                    = N_( "German, Old High (ca.750-1050)" );
+      // language code: gon
+      iso639_2["gon"]                                    = N_( "Gondi" );
+      // language code: gor
+      iso639_2["gor"]                                    = N_( "Gorontalo" );
+      // language code: got
+      iso639_2["got"]                                    = N_( "Gothic" );
+      // language code: grb
+      iso639_2["grb"]                                    = N_( "Grebo" );
+      // language code: grc
+      iso639_2["grc"]                                    = N_( "Greek, Ancient (to 1453)" );
+      // language code: gre ell el
+      iso639_2["gre"] = iso639_2["ell"] = iso639_1["el"] = N_( "Greek, Modern (1453-)" );
+      // language code: grn gn
+      iso639_2["grn"]                   = iso639_1["gn"] = N_( "Guarani" );
+      // language code: guj gu
+      iso639_2["guj"]                   = iso639_1["gu"] = N_( "Gujarati" );
+      // language code: gwi
+      iso639_2["gwi"]                                    = N_( "Gwich'in" );
+      // language code: hai
+      iso639_2["hai"]                                    = N_( "Haida" );
+      // language code: hat ht
+      iso639_2["hat"]                   = iso639_1["ht"] = N_( "Haitian" );
+      // language code: hau ha
+      iso639_2["hau"]                   = iso639_1["ha"] = N_( "Hausa" );
+      // language code: haw
+      iso639_2["haw"]                                    = N_( "Hawaiian" );
+      // language code: heb he
+      iso639_2["heb"]                   = iso639_1["he"] = N_( "Hebrew" );
+      // language code: her hz
+      iso639_2["her"]                   = iso639_1["hz"] = N_( "Herero" );
+      // language code: hil
+      iso639_2["hil"]                                    = N_( "Hiligaynon" );
+      // language code: him
+      iso639_2["him"]                                    = N_( "Himachali" );
+      // language code: hin hi
+      iso639_2["hin"]                   = iso639_1["hi"] = N_( "Hindi" );
+      // language code: hit
+      iso639_2["hit"]                                    = N_( "Hittite" );
+      // language code: hmn
+      iso639_2["hmn"]                                    = N_( "Hmong" );
+      // language code: hmo ho
+      iso639_2["hmo"]                   = iso639_1["ho"] = N_( "Hiri Motu" );
+      // language code: hsb
+      iso639_2["hsb"]                                    = N_( "Upper Sorbian" );
+      // language code: hun hu
+      iso639_2["hun"]                   = iso639_1["hu"] = N_( "Hungarian" );
+      // language code: hup
+      iso639_2["hup"]                                    = N_( "Hupa" );
+      // language code: iba
+      iso639_2["iba"]                                    = N_( "Iban" );
+      // language code: ibo ig
+      iso639_2["ibo"]                   = iso639_1["ig"] = N_( "Igbo" );
+      // language code: ice isl is
+      iso639_2["ice"] = iso639_2["isl"] = iso639_1["is"] = N_( "Icelandic" );
+      // language code: ido io
+      iso639_2["ido"]                   = iso639_1["io"] = N_( "Ido" );
+      // language code: iii ii
+      iso639_2["iii"]                   = iso639_1["ii"] = N_( "Sichuan Yi" );
+      // language code: ijo
+      iso639_2["ijo"]                                    = N_( "Ijo" );
+      // language code: iku iu
+      iso639_2["iku"]                   = iso639_1["iu"] = N_( "Inuktitut" );
+      // language code: ile ie
+      iso639_2["ile"]                   = iso639_1["ie"] = N_( "Interlingue" );
+      // language code: ilo
+      iso639_2["ilo"]                                    = N_( "Iloko" );
+      // language code: ina ia
+      iso639_2["ina"]                   = iso639_1["ia"] = N_( "Interlingua (International Auxiliary Language Association)" );
+      // language code: inc
+      iso639_2["inc"]                                    = N_( "Indic (Other)" );
+      // language code: ind id
+      iso639_2["ind"]                   = iso639_1["id"] = N_( "Indonesian" );
+      // language code: ine
+      iso639_2["ine"]                                    = N_( "Indo-European (Other)" );
+      // language code: inh
+      iso639_2["inh"]                                    = N_( "Ingush" );
+      // language code: ipk ik
+      iso639_2["ipk"]                   = iso639_1["ik"] = N_( "Inupiaq" );
+      // language code: ira
+      iso639_2["ira"]                                    = N_( "Iranian (Other)" );
+      // language code: iro
+      iso639_2["iro"]                                    = N_( "Iroquoian languages" );
+      // language code: ita it
+      iso639_2["ita"]                   = iso639_1["it"] = N_( "Italian" );
+      // language code: jav jv
+      iso639_2["jav"]                   = iso639_1["jv"] = N_( "Javanese" );
+      // language code: jbo
+      iso639_2["jbo"]                                    = N_( "Lojban" );
+      // language code: jpn ja
+      iso639_2["jpn"]                   = iso639_1["ja"] = N_( "Japanese" );
+      // language code: jpr
+      iso639_2["jpr"]                                    = N_( "Judeo-Persian" );
+      // language code: jrb
+      iso639_2["jrb"]                                    = N_( "Judeo-Arabic" );
+      // language code: kaa
+      iso639_2["kaa"]                                    = N_( "Kara-Kalpak" );
+      // language code: kab
+      iso639_2["kab"]                                    = N_( "Kabyle" );
+      // language code: kac
+      iso639_2["kac"]                                    = N_( "Kachin" );
+      // language code: kal kl
+      iso639_2["kal"]                   = iso639_1["kl"] = N_( "Kalaallisut" );
+      // language code: kam
+      iso639_2["kam"]                                    = N_( "Kamba" );
+      // language code: kan kn
+      iso639_2["kan"]                   = iso639_1["kn"] = N_( "Kannada" );
+      // language code: kar
+      iso639_2["kar"]                                    = N_( "Karen" );
+      // language code: kas ks
+      iso639_2["kas"]                   = iso639_1["ks"] = N_( "Kashmiri" );
+      // language code: kau kr
+      iso639_2["kau"]                   = iso639_1["kr"] = N_( "Kanuri" );
+      // language code: kaw
+      iso639_2["kaw"]                                    = N_( "Kawi" );
+      // language code: kaz kk
+      iso639_2["kaz"]                   = iso639_1["kk"] = N_( "Kazakh" );
+      // language code: kbd
+      iso639_2["kbd"]                                    = N_( "Kabardian" );
+      // language code: kha
+      iso639_2["kha"]                                    = N_( "Khasi" );
+      // language code: khi
+      iso639_2["khi"]                                    = N_( "Khoisan (Other)" );
+      // language code: khm km
+      iso639_2["khm"]                   = iso639_1["km"] = N_( "Khmer" );
+      // language code: kho
+      iso639_2["kho"]                                    = N_( "Khotanese" );
+      // language code: kik ki
+      iso639_2["kik"]                   = iso639_1["ki"] = N_( "Kikuyu" );
+      // language code: kin rw
+      iso639_2["kin"]                   = iso639_1["rw"] = N_( "Kinyarwanda" );
+      // language code: kir ky
+      iso639_2["kir"]                   = iso639_1["ky"] = N_( "Kirghiz" );
+      // language code: kmb
+      iso639_2["kmb"]                                    = N_( "Kimbundu" );
+      // language code: kok
+      iso639_2["kok"]                                    = N_( "Konkani" );
+      // language code: kom kv
+      iso639_2["kom"]                   = iso639_1["kv"] = N_( "Komi" );
+      // language code: kon kg
+      iso639_2["kon"]                   = iso639_1["kg"] = N_( "Kongo" );
+      // language code: kor ko
+      iso639_2["kor"]                   = iso639_1["ko"] = N_( "Korean" );
+      // language code: kos
+      iso639_2["kos"]                                    = N_( "Kosraean" );
+      // language code: kpe
+      iso639_2["kpe"]                                    = N_( "Kpelle" );
+      // language code: krc
+      iso639_2["krc"]                                    = N_( "Karachay-Balkar" );
+      // language code: kro
+      iso639_2["kro"]                                    = N_( "Kru" );
+      // language code: kru
+      iso639_2["kru"]                                    = N_( "Kurukh" );
+      // language code: kua kj
+      iso639_2["kua"]                   = iso639_1["kj"] = N_( "Kuanyama" );
+      // language code: kum
+      iso639_2["kum"]                                    = N_( "Kumyk" );
+      // language code: kur ku
+      iso639_2["kur"]                   = iso639_1["ku"] = N_( "Kurdish" );
+      // language code: kut
+      iso639_2["kut"]                                    = N_( "Kutenai" );
+      // language code: lad
+      iso639_2["lad"]                                    = N_( "Ladino" );
+      // language code: lah
+      iso639_2["lah"]                                    = N_( "Lahnda" );
+      // language code: lam
+      iso639_2["lam"]                                    = N_( "Lamba" );
+      // language code: lao lo
+      iso639_2["lao"]                   = iso639_1["lo"] = N_( "Lao" );
+      // language code: lat la
+      iso639_2["lat"]                   = iso639_1["la"] = N_( "Latin" );
+      // language code: lav lv
+      iso639_2["lav"]                   = iso639_1["lv"] = N_( "Latvian" );
+      // language code: lez
+      iso639_2["lez"]                                    = N_( "Lezghian" );
+      // language code: lim li
+      iso639_2["lim"]                   = iso639_1["li"] = N_( "Limburgan" );
+      // language code: lin ln
+      iso639_2["lin"]                   = iso639_1["ln"] = N_( "Lingala" );
+      // language code: lit lt
+      iso639_2["lit"]                   = iso639_1["lt"] = N_( "Lithuanian" );
+      // language code: lol
+      iso639_2["lol"]                                    = N_( "Mongo" );
+      // language code: loz
+      iso639_2["loz"]                                    = N_( "Lozi" );
+      // language code: ltz lb
+      iso639_2["ltz"]                   = iso639_1["lb"] = N_( "Luxembourgish" );
+      // language code: lua
+      iso639_2["lua"]                                    = N_( "Luba-Lulua" );
+      // language code: lub lu
+      iso639_2["lub"]                   = iso639_1["lu"] = N_( "Luba-Katanga" );
+      // language code: lug lg
+      iso639_2["lug"]                   = iso639_1["lg"] = N_( "Ganda" );
+      // language code: lui
+      iso639_2["lui"]                                    = N_( "Luiseno" );
+      // language code: lun
+      iso639_2["lun"]                                    = N_( "Lunda" );
+      // language code: luo
+      iso639_2["luo"]                                    = N_( "Luo (Kenya and Tanzania)" );
+      // language code: lus
+      iso639_2["lus"]                                    = N_( "lushai" );
+      // language code: mac mkd mk
+      iso639_2["mac"] = iso639_2["mkd"] = iso639_1["mk"] = N_( "Macedonian" );
+      // language code: mad
+      iso639_2["mad"]                                    = N_( "Madurese" );
+      // language code: mag
+      iso639_2["mag"]                                    = N_( "Magahi" );
+      // language code: mah mh
+      iso639_2["mah"]                   = iso639_1["mh"] = N_( "Marshallese" );
+      // language code: mai
+      iso639_2["mai"]                                    = N_( "Maithili" );
+      // language code: mak
+      iso639_2["mak"]                                    = N_( "Makasar" );
+      // language code: mal ml
+      iso639_2["mal"]                   = iso639_1["ml"] = N_( "Malayalam" );
+      // language code: man
+      iso639_2["man"]                                    = N_( "Mandingo" );
+      // language code: mao mri mi
+      iso639_2["mao"] = iso639_2["mri"] = iso639_1["mi"] = N_( "Maori" );
+      // language code: map
+      iso639_2["map"]                                    = N_( "Austronesian (Other)" );
+      // language code: mar mr
+      iso639_2["mar"]                   = iso639_1["mr"] = N_( "Marathi" );
+      // language code: mas
+      iso639_2["mas"]                                    = N_( "Masai" );
+      // language code: may msa ms
+      iso639_2["may"] = iso639_2["msa"] = iso639_1["ms"] = N_( "Malay" );
+      // language code: mdf
+      iso639_2["mdf"]                                    = N_( "Moksha" );
+      // language code: mdr
+      iso639_2["mdr"]                                    = N_( "Mandar" );
+      // language code: men
+      iso639_2["men"]                                    = N_( "Mende" );
+      // language code: mga
+      iso639_2["mga"]                                    = N_( "Irish, Middle (900-1200)" );
+      // language code: mic
+      iso639_2["mic"]                                    = N_( "Mi'kmaq" );
+      // language code: min
+      iso639_2["min"]                                    = N_( "Minangkabau" );
+      // language code: mis
+      iso639_2["mis"]                                    = N_( "Miscellaneous languages" );
+      // language code: mkh
+      iso639_2["mkh"]                                    = N_( "Mon-Khmer (Other)" );
+      // language code: mlg mg
+      iso639_2["mlg"]                   = iso639_1["mg"] = N_( "Malagasy" );
+      // language code: mlt mt
+      iso639_2["mlt"]                   = iso639_1["mt"] = N_( "Maltese" );
+      // language code: mnc
+      iso639_2["mnc"]                                    = N_( "Manchu" );
+      // language code: mni
+      iso639_2["mni"]                                    = N_( "Manipuri" );
+      // language code: mno
+      iso639_2["mno"]                                    = N_( "Manobo languages" );
+      // language code: moh
+      iso639_2["moh"]                                    = N_( "Mohawk" );
+      // language code: mol mo
+      iso639_2["mol"]                   = iso639_1["mo"] = N_( "Moldavian" );
+      // language code: mon mn
+      iso639_2["mon"]                   = iso639_1["mn"] = N_( "Mongolian" );
+      // language code: mos
+      iso639_2["mos"]                                    = N_( "Mossi" );
+      // language code: mul
+      iso639_2["mul"]                                    = N_( "Multiple languages" );
+      // language code: mun
+      iso639_2["mun"]                                    = N_( "Munda languages" );
+      // language code: mus
+      iso639_2["mus"]                                    = N_( "Creek" );
+      // language code: mwl
+      iso639_2["mwl"]                                    = N_( "Mirandese" );
+      // language code: mwr
+      iso639_2["mwr"]                                    = N_( "Marwari" );
+      // language code: myn
+      iso639_2["myn"]                                    = N_( "Mayan languages" );
+      // language code: myv
+      iso639_2["myv"]                                    = N_( "Erzya" );
+      // language code: nah
+      iso639_2["nah"]                                    = N_( "Nahuatl" );
+      // language code: nai
+      iso639_2["nai"]                                    = N_( "North American Indian" );
+      // language code: nap
+      iso639_2["nap"]                                    = N_( "Neapolitan" );
+      // language code: nau na
+      iso639_2["nau"]                   = iso639_1["na"] = N_( "Nauru" );
+      // language code: nav nv
+      iso639_2["nav"]                   = iso639_1["nv"] = N_( "Navajo" );
+      // language code: nbl nr
+      iso639_2["nbl"]                   = iso639_1["nr"] = N_( "Ndebele, South" );
+      // language code: nde nd
+      iso639_2["nde"]                   = iso639_1["nd"] = N_( "Ndebele, North" );
+      // language code: ndo ng
+      iso639_2["ndo"]                   = iso639_1["ng"] = N_( "Ndonga" );
+      // language code: nds
+      iso639_2["nds"]                                    = N_( "Low German" );
+      // language code: nep ne
+      iso639_2["nep"]                   = iso639_1["ne"] = N_( "Nepali" );
+      // language code: new
+      iso639_2["new"]                                    = N_( "Nepal Bhasa" );
+      // language code: nia
+      iso639_2["nia"]                                    = N_( "Nias" );
+      // language code: nic
+      iso639_2["nic"]                                    = N_( "Niger-Kordofanian (Other)" );
+      // language code: niu
+      iso639_2["niu"]                                    = N_( "Niuean" );
+      // language code: nno nn
+      iso639_2["nno"]                   = iso639_1["nn"] = N_( "Norwegian Nynorsk" );
+      // language code: nob nb
+      iso639_2["nob"]                   = iso639_1["nb"] = N_( "Norwegian Bokmal" );
+      // language code: nog
+      iso639_2["nog"]                                    = N_( "Nogai" );
+      // language code: non
+      iso639_2["non"]                                    = N_( "Norse, Old" );
+      // language code: nor no
+      iso639_2["nor"]                   = iso639_1["no"] = N_( "Norwegian" );
+      // language code: nso
+      iso639_2["nso"]                                    = N_( "Northern Sotho" );
+      // language code: nub
+      iso639_2["nub"]                                    = N_( "Nubian languages" );
+      // language code: nwc
+      iso639_2["nwc"]                                    = N_( "Classical Newari" );
+      // language code: nya ny
+      iso639_2["nya"]                   = iso639_1["ny"] = N_( "Chichewa" );
+      // language code: nym
+      iso639_2["nym"]                                    = N_( "Nyamwezi" );
+      // language code: nyn
+      iso639_2["nyn"]                                    = N_( "Nyankole" );
+      // language code: nyo
+      iso639_2["nyo"]                                    = N_( "Nyoro" );
+      // language code: nzi
+      iso639_2["nzi"]                                    = N_( "Nzima" );
+      // language code: oci oc
+      iso639_2["oci"]                   = iso639_1["oc"] = N_( "Occitan (post 1500)" );
+      // language code: oji oj
+      iso639_2["oji"]                   = iso639_1["oj"] = N_( "Ojibwa" );
+      // language code: ori or
+      iso639_2["ori"]                   = iso639_1["or"] = N_( "Oriya" );
+      // language code: orm om
+      iso639_2["orm"]                   = iso639_1["om"] = N_( "Oromo" );
+      // language code: osa
+      iso639_2["osa"]                                    = N_( "Osage" );
+      // language code: oss os
+      iso639_2["oss"]                   = iso639_1["os"] = N_( "Ossetian" );
+      // language code: ota
+      iso639_2["ota"]                                    = N_( "Turkish, Ottoman (1500-1928)" );
+      // language code: oto
+      iso639_2["oto"]                                    = N_( "Otomian languages" );
+      // language code: paa
+      iso639_2["paa"]                                    = N_( "Papuan (Other)" );
+      // language code: pag
+      iso639_2["pag"]                                    = N_( "Pangasinan" );
+      // language code: pal
+      iso639_2["pal"]                                    = N_( "Pahlavi" );
+      // language code: pam
+      iso639_2["pam"]                                    = N_( "Pampanga" );
+      // language code: pan pa
+      iso639_2["pan"]                   = iso639_1["pa"] = N_( "Panjabi" );
+      // language code: pap
+      iso639_2["pap"]                                    = N_( "Papiamento" );
+      // language code: pau
+      iso639_2["pau"]                                    = N_( "Palauan" );
+      // language code: peo
+      iso639_2["peo"]                                    = N_( "Persian, Old (ca.600-400 B.C.)" );
+      // language code: per fas fa
+      iso639_2["per"] = iso639_2["fas"] = iso639_1["fa"] = N_( "Persian" );
+      // language code: phi
+      iso639_2["phi"]                                    = N_( "Philippine (Other)" );
+      // language code: phn
+      iso639_2["phn"]                                    = N_( "Phoenician" );
+      // language code: pli pi
+      iso639_2["pli"]                   = iso639_1["pi"] = N_( "Pali" );
+      // language code: pol pl
+      iso639_2["pol"]                   = iso639_1["pl"] = N_( "Polish" );
+      // language code: pon
+      iso639_2["pon"]                                    = N_( "Pohnpeian" );
+      // language code: por pt
+      iso639_2["por"]                   = iso639_1["pt"] = N_( "Portuguese" );
+      // language code: pra
+      iso639_2["pra"]                                    = N_( "Prakrit languages" );
+      // language code: pro
+      iso639_2["pro"]                                    = N_( "Provencal, Old (to 1500)" );
+      // language code: pus ps
+      iso639_2["pus"]                   = iso639_1["ps"] = N_( "Pushto" );
+      // language code: que qu
+      iso639_2["que"]                   = iso639_1["qu"] = N_( "Quechua" );
+      // language code: raj
+      iso639_2["raj"]                                    = N_( "Rajasthani" );
+      // language code: rap
+      iso639_2["rap"]                                    = N_( "Rapanui" );
+      // language code: rar
+      iso639_2["rar"]                                    = N_( "Rarotongan" );
+      // language code: roa
+      iso639_2["roa"]                                    = N_( "Romance (Other)" );
+      // language code: roh rm
+      iso639_2["roh"]                   = iso639_1["rm"] = N_( "Raeto-Romance" );
+      // language code: rom
+      iso639_2["rom"]                                    = N_( "Romany" );
+      // language code: rum ron ro
+      iso639_2["rum"] = iso639_2["ron"] = iso639_1["ro"] = N_( "Romanian" );
+      // language code: run rn
+      iso639_2["run"]                   = iso639_1["rn"] = N_( "Rundi" );
+      // language code: rus ru
+      iso639_2["rus"]                   = iso639_1["ru"] = N_( "Russian" );
+      // language code: sad
+      iso639_2["sad"]                                    = N_( "Sandawe" );
+      // language code: sag sg
+      iso639_2["sag"]                   = iso639_1["sg"] = N_( "Sango" );
+      // language code: sah
+      iso639_2["sah"]                                    = N_( "Yakut" );
+      // language code: sai
+      iso639_2["sai"]                                    = N_( "South American Indian (Other)" );
+      // language code: sal
+      iso639_2["sal"]                                    = N_( "Salishan languages" );
+      // language code: sam
+      iso639_2["sam"]                                    = N_( "Samaritan Aramaic" );
+      // language code: san sa
+      iso639_2["san"]                   = iso639_1["sa"] = N_( "Sanskrit" );
+      // language code: sas
+      iso639_2["sas"]                                    = N_( "Sasak" );
+      // language code: sat
+      iso639_2["sat"]                                    = N_( "Santali" );
+      // language code: scc srp sr
+      iso639_2["scc"] = iso639_2["srp"] = iso639_1["sr"] = N_( "Serbian" );
+      // language code: scn
+      iso639_2["scn"]                                    = N_( "Sicilian" );
+      // language code: sco
+      iso639_2["sco"]                                    = N_( "Scots" );
+      // language code: scr hrv hr
+      iso639_2["scr"] = iso639_2["hrv"] = iso639_1["hr"] = N_( "Croatian" );
+      // language code: sel
+      iso639_2["sel"]                                    = N_( "Selkup" );
+      // language code: sem
+      iso639_2["sem"]                                    = N_( "Semitic (Other)" );
+      // language code: sga
+      iso639_2["sga"]                                    = N_( "Irish, Old (to 900)" );
+      // language code: sgn
+      iso639_2["sgn"]                                    = N_( "Sign Languages" );
+      // language code: shn
+      iso639_2["shn"]                                    = N_( "Shan" );
+      // language code: sid
+      iso639_2["sid"]                                    = N_( "Sidamo" );
+      // language code: sin si
+      iso639_2["sin"]                   = iso639_1["si"] = N_( "Sinhala" );
+      // language code: sio
+      iso639_2["sio"]                                    = N_( "Siouan languages" );
+      // language code: sit
+      iso639_2["sit"]                                    = N_( "Sino-Tibetan (Other)" );
+      // language code: sla
+      iso639_2["sla"]                                    = N_( "Slavic (Other)" );
+      // language code: slo slk sk
+      iso639_2["slo"] = iso639_2["slk"] = iso639_1["sk"] = N_( "Slovak" );
+      // language code: slv sl
+      iso639_2["slv"]                   = iso639_1["sl"] = N_( "Slovenian" );
+      // language code: sma
+      iso639_2["sma"]                                    = N_( "Southern Sami" );
+      // language code: sme se
+      iso639_2["sme"]                   = iso639_1["se"] = N_( "Northern Sami" );
+      // language code: smi
+      iso639_2["smi"]                                    = N_( "Sami languages (Other)" );
+      // language code: smj
+      iso639_2["smj"]                                    = N_( "Lule Sami" );
+      // language code: smn
+      iso639_2["smn"]                                    = N_( "Inari Sami" );
+      // language code: smo sm
+      iso639_2["smo"]                   = iso639_1["sm"] = N_( "Samoan" );
+      // language code: sms
+      iso639_2["sms"]                                    = N_( "Skolt Sami" );
+      // language code: sna sn
+      iso639_2["sna"]                   = iso639_1["sn"] = N_( "Shona" );
+      // language code: snd sd
+      iso639_2["snd"]                   = iso639_1["sd"] = N_( "Sindhi" );
+      // language code: snk
+      iso639_2["snk"]                                    = N_( "Soninke" );
+      // language code: sog
+      iso639_2["sog"]                                    = N_( "Sogdian" );
+      // language code: som so
+      iso639_2["som"]                   = iso639_1["so"] = N_( "Somali" );
+      // language code: son
+      iso639_2["son"]                                    = N_( "Songhai" );
+      // language code: sot st
+      iso639_2["sot"]                   = iso639_1["st"] = N_( "Sotho, Southern" );
+      // language code: spa es
+      iso639_2["spa"]                   = iso639_1["es"] = N_( "Spanish" );
+      // language code: srd sc
+      iso639_2["srd"]                   = iso639_1["sc"] = N_( "Sardinian" );
+      // language code: srr
+      iso639_2["srr"]                                    = N_( "Serer" );
+      // language code: ssa
+      iso639_2["ssa"]                                    = N_( "Nilo-Saharan (Other)" );
+      // language code: ssw ss
+      iso639_2["ssw"]                   = iso639_1["ss"] = N_( "Swati" );
+      // language code: suk
+      iso639_2["suk"]                                    = N_( "Sukuma" );
+      // language code: sun su
+      iso639_2["sun"]                   = iso639_1["su"] = N_( "Sundanese" );
+      // language code: sus
+      iso639_2["sus"]                                    = N_( "Susu" );
+      // language code: sux
+      iso639_2["sux"]                                    = N_( "Sumerian" );
+      // language code: swa sw
+      iso639_2["swa"]                   = iso639_1["sw"] = N_( "Swahili" );
+      // language code: swe sv
+      iso639_2["swe"]                   = iso639_1["sv"] = N_( "Swedish" );
+      // language code: syr
+      iso639_2["syr"]                                    = N_( "Syriac" );
+      // language code: tah ty
+      iso639_2["tah"]                   = iso639_1["ty"] = N_( "Tahitian" );
+      // language code: tai
+      iso639_2["tai"]                                    = N_( "Tai (Other)" );
+      // language code: tam ta
+      iso639_2["tam"]                   = iso639_1["ta"] = N_( "Tamil" );
+      // language code: tat tt
+      iso639_2["tat"]                   = iso639_1["tt"] = N_( "Tatar" );
+      // language code: tel te
+      iso639_2["tel"]                   = iso639_1["te"] = N_( "Telugu" );
+      // language code: tem
+      iso639_2["tem"]                                    = N_( "Timne" );
+      // language code: ter
+      iso639_2["ter"]                                    = N_( "Tereno" );
+      // language code: tet
+      iso639_2["tet"]                                    = N_( "Tetum" );
+      // language code: tgk tg
+      iso639_2["tgk"]                   = iso639_1["tg"] = N_( "Tajik" );
+      // language code: tgl tl
+      iso639_2["tgl"]                   = iso639_1["tl"] = N_( "Tagalog" );
+      // language code: tha th
+      iso639_2["tha"]                   = iso639_1["th"] = N_( "Thai" );
+      // language code: tib bod bo
+      iso639_2["tib"] = iso639_2["bod"] = iso639_1["bo"] = N_( "Tibetan" );
+      // language code: tig
+      iso639_2["tig"]                                    = N_( "Tigre" );
+      // language code: tir ti
+      iso639_2["tir"]                   = iso639_1["ti"] = N_( "Tigrinya" );
+      // language code: tiv
+      iso639_2["tiv"]                                    = N_( "Tiv" );
+      // language code: tkl
+      iso639_2["tkl"]                                    = N_( "Tokelau" );
+      // language code: tlh
+      iso639_2["tlh"]                                    = N_( "Klingon" );
+      // language code: tli
+      iso639_2["tli"]                                    = N_( "Tlingit" );
+      // language code: tmh
+      iso639_2["tmh"]                                    = N_( "Tamashek" );
+      // language code: tog
+      iso639_2["tog"]                                    = N_( "Tonga (Nyasa)" );
+      // language code: ton to
+      iso639_2["ton"]                   = iso639_1["to"] = N_( "Tonga (Tonga Islands)" );
+      // language code: tpi
+      iso639_2["tpi"]                                    = N_( "Tok Pisin" );
+      // language code: tsi
+      iso639_2["tsi"]                                    = N_( "Tsimshian" );
+      // language code: tsn tn
+      iso639_2["tsn"]                   = iso639_1["tn"] = N_( "Tswana" );
+      // language code: tso ts
+      iso639_2["tso"]                   = iso639_1["ts"] = N_( "Tsonga" );
+      // language code: tuk tk
+      iso639_2["tuk"]                   = iso639_1["tk"] = N_( "Turkmen" );
+      // language code: tum
+      iso639_2["tum"]                                    = N_( "Tumbuka" );
+      // language code: tup
+      iso639_2["tup"]                                    = N_( "Tupi languages" );
+      // language code: tur tr
+      iso639_2["tur"]                   = iso639_1["tr"] = N_( "Turkish" );
+      // language code: tut
+      iso639_2["tut"]                                    = N_( "Altaic (Other)" );
+      // language code: tvl
+      iso639_2["tvl"]                                    = N_( "Tuvalu" );
+      // language code: twi tw
+      iso639_2["twi"]                   = iso639_1["tw"] = N_( "Twi" );
+      // language code: tyv
+      iso639_2["tyv"]                                    = N_( "Tuvinian" );
+      // language code: udm
+      iso639_2["udm"]                                    = N_( "Udmurt" );
+      // language code: uga
+      iso639_2["uga"]                                    = N_( "Ugaritic" );
+      // language code: uig ug
+      iso639_2["uig"]                   = iso639_1["ug"] = N_( "Uighur" );
+      // language code: ukr uk
+      iso639_2["ukr"]                   = iso639_1["uk"] = N_( "Ukrainian" );
+      // language code: umb
+      iso639_2["umb"]                                    = N_( "Umbundu" );
+      // language code: und
+      iso639_2["und"]                                    = N_( "Undetermined" );
+      // language code: urd ur
+      iso639_2["urd"]                   = iso639_1["ur"] = N_( "Urdu" );
+      // language code: uzb uz
+      iso639_2["uzb"]                   = iso639_1["uz"] = N_( "Uzbek" );
+      // language code: vai
+      iso639_2["vai"]                                    = N_( "Vai" );
+      // language code: ven ve
+      iso639_2["ven"]                   = iso639_1["ve"] = N_( "Venda" );
+      // language code: vie vi
+      iso639_2["vie"]                   = iso639_1["vi"] = N_( "Vietnamese" );
+      // language code: vol vo
+      iso639_2["vol"]                   = iso639_1["vo"] = N_( "Volapuk" );
+      // language code: vot
+      iso639_2["vot"]                                    = N_( "Votic" );
+      // language code: wak
+      iso639_2["wak"]                                    = N_( "Wakashan languages" );
+      // language code: wal
+      iso639_2["wal"]                                    = N_( "Walamo" );
+      // language code: war
+      iso639_2["war"]                                    = N_( "Waray" );
+      // language code: was
+      iso639_2["was"]                                    = N_( "Washo" );
+      // language code: wel cym cy
+      iso639_2["wel"] = iso639_2["cym"] = iso639_1["cy"] = N_( "Welsh" );
+      // language code: wen
+      iso639_2["wen"]                                    = N_( "Sorbian languages" );
+      // language code: wln wa
+      iso639_2["wln"]                   = iso639_1["wa"] = N_( "Walloon" );
+      // language code: wol wo
+      iso639_2["wol"]                   = iso639_1["wo"] = N_( "Wolof" );
+      // language code: xal
+      iso639_2["xal"]                                    = N_( "Kalmyk" );
+      // language code: xho xh
+      iso639_2["xho"]                   = iso639_1["xh"] = N_( "Xhosa" );
+      // language code: yao
+      iso639_2["yao"]                                    = N_( "Yao" );
+      // language code: yap
+      iso639_2["yap"]                                    = N_( "Yapese" );
+      // language code: yid yi
+      iso639_2["yid"]                   = iso639_1["yi"] = N_( "Yiddish" );
+      // language code: yor yo
+      iso639_2["yor"]                   = iso639_1["yo"] = N_( "Yoruba" );
+      // language code: ypk
+      iso639_2["ypk"]                                    = N_( "Yupik languages" );
+      // language code: zap
+      iso639_2["zap"]                                    = N_( "Zapotec" );
+      // language code: zen
+      iso639_2["zen"]                                    = N_( "Zenaga" );
+      // language code: zha za
+      iso639_2["zha"]                   = iso639_1["za"] = N_( "Zhuang" );
+      // language code: znd
+      iso639_2["znd"]                                    = N_( "Zande" );
+      // language code: zul zu
+      iso639_2["zul"]                   = iso639_1["zu"] = N_( "Zulu" );
+      // language code: zun
+      iso639_2["zun"]                                    = N_( "Zuni" );
+    }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace
+  ///////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/LanguageCode.h b/zypp/LanguageCode.h
new file mode 100644 (file)
index 0000000..71f3f28
--- /dev/null
@@ -0,0 +1,122 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/LanguageCode.h
+ *
+*/
+#ifndef ZYPP_LANGUAGECODE_H
+#define ZYPP_LANGUAGECODE_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/base/PtrTypes.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : LanguageCode
+  //
+  /** Language codes (iso639_2/iso639_1).
+   *
+   * In fact the class will not prevent to use a non iso language code.
+   * Just a warning will appear in the log.
+  */
+  class LanguageCode
+  {
+    friend std::ostream & operator<<( std::ostream & str, const LanguageCode & obj );
+
+  public:
+    /** Implementation  */
+    class Impl;
+
+  public:
+    /** Default ctor */
+    LanguageCode();
+
+    /** Ctor taking a string. */
+    explicit
+    LanguageCode( const std::string & code_r );
+
+    /** Dtor */
+    ~LanguageCode();
+
+  public:
+
+    /** \name LanguageCode constants. */
+    //@{
+    /** No or empty code. */
+    static const LanguageCode noCode;
+    /** Advice to use some default code. */
+    static const LanguageCode useDefault;
+    //@}
+
+  public:
+    /** Return the language code. */
+    std::string code() const;
+
+    /** Return the language name; if not available the language code. */
+    std::string name() const;
+
+  private:
+    /** Pointer to implementation */
+    RW_pointer<Impl> _pimpl;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /** \relates LanguageCode Stream output */
+  inline std::ostream & operator<<( std::ostream & str, const LanguageCode & obj )
+  { return str << obj.code(); }
+
+  /** Comparison based on string value. */
+  //@{
+  /** \relates LanguageCode */
+  inline bool operator==( const LanguageCode & lhs, const LanguageCode & rhs ) {
+    return( lhs.code() == rhs.code() );
+  }
+  /** \relates LanguageCode */
+  inline bool operator==( const std::string & lhs, const LanguageCode & rhs ) {
+    return( lhs == rhs.code() );
+  }
+  /** \relates LanguageCode */
+  inline bool operator==( const LanguageCode & lhs, const std::string & rhs ) {
+    return( lhs.code() == rhs );
+  }
+
+  /** \relates LanguageCode */
+  inline bool operator!=( const LanguageCode & lhs, const LanguageCode & rhs ) {
+    return( ! operator==( lhs, rhs ) );
+  }
+  /** \relates LanguageCode */
+  inline bool operator!=( const std::string & lhs, const LanguageCode & rhs ) {
+    return( ! operator==( lhs, rhs ) );
+  }
+  /** \relates LanguageCode */
+  inline bool operator!=( const LanguageCode & lhs, const std::string & rhs ) {
+    return( ! operator==( lhs, rhs ) );
+  }
+  //@}
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+namespace std
+{ /////////////////////////////////////////////////////////////////
+  /** \relates LanguageCode Default order for std::container based on code string value.*/
+  template<>
+    inline bool less<zypp::LanguageCode>::operator()( const zypp::LanguageCode & lhs, const zypp::LanguageCode & rhs ) const
+    { return lhs.code() < rhs.code(); }
+  /////////////////////////////////////////////////////////////////
+} // namespace std
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_LANGUAGECODE_H
index 5371b88..d6994e1 100644 (file)
@@ -11,9 +11,11 @@ include_HEADERS = NeedAType.h \
        Capability.h    \
        CapFactory.h    \
        CapSet.h        \
+       CountryCode.h   \
        Date.h          \
        Dependencies.h  \
        Edition.h       \
+       LanguageCode.h  \
        Rel.h           \
        ResObject.h     \
        Resolvable.h    \
@@ -47,9 +49,11 @@ lib@PACKAGE@_la_SOURCES = \
        Capability.cc   \
        CapFactory.cc   \
        CapSet.cc       \
+       CountryCode.cc  \
        Date.cc         \
        Dependencies.cc \
        Edition.cc      \
+       LanguageCode.cc \
        Rel.cc          \
        ResObject.cc    \
        Resolvable.cc   \
diff --git a/zypp/base/Gettext.cc b/zypp/base/Gettext.cc
new file mode 100644 (file)
index 0000000..f90ec91
--- /dev/null
@@ -0,0 +1,63 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/base/Gettext.cc
+ *
+*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+extern "C" {
+#include <libintl.h>
+}
+
+#include "zypp/base/Gettext.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace gettext
+  { /////////////////////////////////////////////////////////////////
+
+    /////////////////////////////////////////////////////////////////
+    // TEXTDOMAIN and LOCALEDIR must be provided via config.h
+    // or at compile time using -D.
+    /////////////////////////////////////////////////////////////////
+
+    inline void assertInit()
+    {
+      static bool initialized = false;
+      if ( ! initialized )
+        {
+          ::bindtextdomain( TEXTDOMAIN, LOCALEDIR );
+          ::bind_textdomain_codeset( TEXTDOMAIN, "UTF-8" );
+          initialized = true;
+        }
+    }
+
+    const char * dgettext( const char * msgid )
+    {
+      assertInit();
+      return ::dgettext( TEXTDOMAIN, msgid );
+    }
+
+    const char * dngettext( const char * msgid1, const char * msgid2,
+                            unsigned long n )
+    {
+      assertInit();
+      return ::dngettext( TEXTDOMAIN, msgid1, msgid2, n );
+    }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace gettext
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/base/Gettext.h b/zypp/base/Gettext.h
new file mode 100644 (file)
index 0000000..a3e0ee0
--- /dev/null
@@ -0,0 +1,47 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/base/Gettext.h
+ *
+ * Interface to gettext.
+ *
+ * \todo Use config.h for TEXTDOMAIN/LOCALEDIR.
+*/
+#ifndef ZYPP_BASE_GETTEXT_H
+#define ZYPP_BASE_GETTEXT_H
+
+/** Just tag text for translation. */
+#define N_(MSG) MSG
+
+/** Return translated text. */
+#define _(MSG) ::zypp::gettext::dgettext( MSG )
+
+/** Return translated text (plural form). */
+#define _PL(MSG1,MSG2,N) ::zypp::gettext::dngettext( MSG1; MSG2, N )
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace gettext
+  { /////////////////////////////////////////////////////////////////
+
+    /** Return translated text. */
+    const char * dgettext( const char * msgid );
+
+    /** Return translated text (plural form). */
+    const char * dngettext( const char * msgid1, const char * msgid2,
+                            unsigned long n );
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace gettext
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_BASE_GETTEXT_H
index a82b3d7..1fdb11a 100644 (file)
@@ -11,6 +11,7 @@ include_HEADERS =     \
        KindOf.h        \
        Logger.h        \
        Exception.h     \
+       Gettext.h       \
        IOStream.h      \
        NonCopyable.h   \
        PtrTypes.h      \
@@ -30,6 +31,7 @@ lib@PACKAGE@_base_la_SOURCES =        \
        Logger.cc       \
        Exception.cc    \
        Fd.cc           \
+       Gettext.cc      \
        IOStream.cc     \
        ReferenceCounted.cc     \
        String.cc       \
index 6a2219d..9b9bd4e 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <string>
 #include <map>
+#include <list>
 
 #include "zypp/base/ReferenceCounted.h"
 #include "zypp/base/NonCopyable.h"
@@ -67,7 +68,7 @@ namespace zypp {
       , _https( https_r )
       , _no_proxy( no_proxy_r )
       {}
-  
+
     public:
       /**  */
       const bool & enabled() const
@@ -84,7 +85,7 @@ namespace zypp {
       /**  */
       const std::list<std::string> & noProxy() const
       { return _no_proxy; }
-  
+
      protected:
       bool _enabled;
       std::string _http;