Add charset support to wxLocaleIdent and accessors
Charset is important for Unix systems as some locales may not be available without it, e.g. "xx_XX" may not be supported, but "xx_XX.utf8" could be.
This commit is contained in:
@@ -140,20 +140,34 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set script
|
// Set script (not supported under Unix)
|
||||||
wxLocaleIdent& Script(const wxString& script)
|
wxLocaleIdent& Script(const wxString& script)
|
||||||
{
|
{
|
||||||
m_script = script;
|
m_script = script;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set modifier
|
// Set charset (only supported under Unix)
|
||||||
|
wxLocaleIdent& Charset(const wxString& charset)
|
||||||
|
{
|
||||||
|
m_charset = charset;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set modifier (only supported under Unix)
|
||||||
wxLocaleIdent& Modifier(const wxString& modifier)
|
wxLocaleIdent& Modifier(const wxString& modifier)
|
||||||
{
|
{
|
||||||
m_modifier = modifier;
|
m_modifier = modifier;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Accessors for the individual fields.
|
||||||
|
const wxString& GetLanguage() const { return m_language; }
|
||||||
|
const wxString& GetRegion() const { return m_region; }
|
||||||
|
const wxString& GetScript() const { return m_script; }
|
||||||
|
const wxString& GetCharset() const { return m_charset; }
|
||||||
|
const wxString& GetModifier() const { return m_modifier; }
|
||||||
|
|
||||||
// Construct platform dependent name
|
// Construct platform dependent name
|
||||||
wxString GetName() const;
|
wxString GetName() const;
|
||||||
|
|
||||||
@@ -167,6 +181,7 @@ private:
|
|||||||
wxString m_language;
|
wxString m_language;
|
||||||
wxString m_region;
|
wxString m_region;
|
||||||
wxString m_script;
|
wxString m_script;
|
||||||
|
wxString m_charset;
|
||||||
wxString m_modifier;
|
wxString m_modifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -218,6 +218,9 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Set script.
|
Set script.
|
||||||
|
|
||||||
|
Note that script value is currently ignored under Unix systems.
|
||||||
|
|
||||||
Return reference to @this for method chaining.
|
Return reference to @this for method chaining.
|
||||||
|
|
||||||
@param script
|
@param script
|
||||||
@@ -225,8 +228,26 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxLocaleIdent& Script(const wxString& script);
|
wxLocaleIdent& Script(const wxString& script);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set charset.
|
||||||
|
|
||||||
|
Note that this value is only used under Unix systems and simply ignored
|
||||||
|
under the other ones.
|
||||||
|
|
||||||
|
Return reference to @this for method chaining.
|
||||||
|
|
||||||
|
@param charset
|
||||||
|
Charset is a string such as "UTF-8", "ISO855915" or "KOI8R".
|
||||||
|
Supported charsets depend on the implementation and installation.
|
||||||
|
*/
|
||||||
|
wxLocaleIdent& Charset(const wxString& charset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set modifier.
|
Set modifier.
|
||||||
|
|
||||||
|
Note that this value is only used under Unix systems and simply ignored
|
||||||
|
under the other ones.
|
||||||
|
|
||||||
Return reference to @this for method chaining.
|
Return reference to @this for method chaining.
|
||||||
|
|
||||||
@param modifier
|
@param modifier
|
||||||
@@ -235,11 +256,26 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxLocaleIdent& Modifier(const wxString& modifier);
|
wxLocaleIdent& Modifier(const wxString& modifier);
|
||||||
|
|
||||||
|
/// Return the language part of the locale identifier.
|
||||||
|
const wxString& GetLanguage() const;
|
||||||
|
|
||||||
|
/// Return the region part of the locale identifier.
|
||||||
|
const wxString& GetRegion() const;
|
||||||
|
|
||||||
|
/// Return the script part of the locale identifier.
|
||||||
|
const wxString& GetScript() const;
|
||||||
|
|
||||||
|
/// Return the charset part of the locale identifier.
|
||||||
|
const wxString& GetCharset() const;
|
||||||
|
|
||||||
|
/// Return the modifier part of the locale identifier.
|
||||||
|
const wxString& GetModifier() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Construct platform dependent name.
|
Construct platform dependent name.
|
||||||
Format:
|
Format:
|
||||||
Windows: <language>-<script>-<REGION>
|
Windows: <language>-<script>-<REGION>
|
||||||
Unix: <language>_<REGION>@<modifier>
|
Unix: <language>_<REGION>.<charset>@<modifier>
|
||||||
MacOS: <language>-<script>_<REGION>
|
MacOS: <language>-<script>_<REGION>
|
||||||
*/
|
*/
|
||||||
wxString GetName() const;
|
wxString GetName() const;
|
||||||
|
@@ -67,6 +67,9 @@ wxString wxLocaleIdent::GetName() const
|
|||||||
if ( !m_region.empty() )
|
if ( !m_region.empty() )
|
||||||
name << "_" << m_region;
|
name << "_" << m_region;
|
||||||
|
|
||||||
|
if ( !m_charset.empty() )
|
||||||
|
name << "." << m_charset;
|
||||||
|
|
||||||
if ( !m_modifier.empty() )
|
if ( !m_modifier.empty() )
|
||||||
name << "@" << m_modifier;
|
name << "@" << m_modifier;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user