Refactor wxTranslationsLoader API.
Instead of calling back into wxTranslations to actually load the data, return wxMsgCatalog instance from wxTranslationsLoader::LoadCatalog(). This requires making wxMsgCatalog public. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -169,20 +169,6 @@ public:
|
||||
*/
|
||||
bool IsLoaded(const wxString& domain) const;
|
||||
|
||||
/**
|
||||
Directly loads catalog from a file.
|
||||
|
||||
It is caller's responsibility to ensure that the catalog contains
|
||||
correct language. This function is primarily intended for
|
||||
wxTranslationsLoader implementations.
|
||||
|
||||
@param filename Name of the MO file to load.
|
||||
@param domain Domain to load the translations into (typically
|
||||
matches file's basename).
|
||||
*/
|
||||
bool LoadCatalogFile(const wxString& filename,
|
||||
const wxString& domain = wxEmptyString);
|
||||
|
||||
/**
|
||||
Retrieves the translation for a string in all loaded domains unless the @a domain
|
||||
parameter is specified (and then only this catalog/domain is searched).
|
||||
@@ -264,10 +250,10 @@ public:
|
||||
/**
|
||||
Called to load requested catalog.
|
||||
|
||||
If the catalog is found, LoadCatalog() should call LoadCatalogFile()
|
||||
on @a translations to add the translation.
|
||||
If the catalog is found, LoadCatalog() should create wxMsgCatalog
|
||||
instance with its data and return it. The caller will take ownership
|
||||
of the catalog.
|
||||
|
||||
@param translations wxTranslations requesting loading.
|
||||
@param domain Domain to load.
|
||||
@param lang Language to look for. This is "canonical name"
|
||||
(see wxLocale::GetCanonicalName()), i.e. ISO 639
|
||||
@@ -275,10 +261,10 @@ public:
|
||||
additional modifiers (e.g. "fr", "en_GB" or
|
||||
"ca@valencia").
|
||||
|
||||
@return @true on successful load, @false otherwise
|
||||
@return Loaded catalog or NULL on failure.
|
||||
*/
|
||||
virtual bool LoadCatalog(wxTranslations *translations,
|
||||
const wxString& domain, const wxString& lang) = 0;
|
||||
virtual wxMsgCatalog *LoadCatalog(const wxString& domain,
|
||||
const wxString& lang) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -335,7 +321,6 @@ public:
|
||||
This class is only available on Windows.
|
||||
|
||||
@since 2.9.1
|
||||
|
||||
*/
|
||||
class wxResourceTranslationsLoader : public wxTranslationsLoader
|
||||
{
|
||||
@@ -356,6 +341,42 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Represents a loaded translations message catalog.
|
||||
|
||||
This class should only be used directly by wxTranslationsLoader
|
||||
implementations.
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
class wxMsgCatalog
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Creates catalog loaded from a MO file.
|
||||
|
||||
@param filename Path to the MO file to load.
|
||||
@param domain Catalog's domain. This typically matches
|
||||
the @a filename.
|
||||
|
||||
@return Successfully loaded catalog or NULL on failure.
|
||||
*/
|
||||
static wxMsgCatalog *CreateFromFile(const wxString& filename,
|
||||
const wxString& domain);
|
||||
|
||||
/**
|
||||
Creates catalog from MO file data in memory buffer.
|
||||
|
||||
@param data Data in MO file format.
|
||||
@param domain Catalog's domain. This typically matches
|
||||
the @a filename.
|
||||
|
||||
@return Successfully loaded catalog or NULL on failure.
|
||||
*/
|
||||
static wxMsgCatalog *CreateFromData(const wxScopedCharBuffer& data,
|
||||
const wxString& domain);
|
||||
};
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// Global functions/macros
|
||||
|
Reference in New Issue
Block a user