1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Michael Andres <ma@suse.de>
16 Maintainer: Michael Andres <ma@suse.de>
22 #include <y2util/LangCode.h>
26 ///////////////////////////////////////////////////////////////////
29 // METHOD NAME : LangCode::LangCode
30 // METHOD TYPE : Constructor
32 LangCode::LangCode( const std::string & code_r )
35 string::size_type sep = code_r.find_first_of( "@." );
36 if ( sep == string::npos ) {
39 t = code_r.substr( 0, sep );
43 if ( sep == string::npos ) {
44 _language = ISOLanguage( t );
46 _language = ISOLanguage( t.substr( 0, sep ) );
47 _country = ISOCountry( t.substr( sep+1 ) );
52 ///////////////////////////////////////////////////////////////////
55 // METHOD NAME : LangCode::code
56 // METHOD TYPE : std::string
58 std::string LangCode::code() const
60 string ret( languageCode() );
62 ret += "_" + countryCode();
66 ///////////////////////////////////////////////////////////////////
69 // METHOD NAME : LangCode::name
70 // METHOD TYPE : std::string
72 std::string LangCode::name() const
74 string ret( languageName() );
76 ret += " (" + countryName() + ")";
80 /******************************************************************
83 ** FUNCTION NAME : operator<<
84 ** FUNCTION TYPE : std::ostream &
86 std::ostream & operator<<( std::ostream & str, const LangCode & obj )
88 return str << obj.code();