26 #include "kcatalogue.h"
27 #include "tdestandarddirs.h"
29 char *k_nl_find_msg(
struct kde_loaded_l10nfile *domain_file,
31 void k_nl_unload_domain (
struct loaded_domain *domain);
33 #ifndef KDE_USE_FINAL // with --enable-final, we're getting this from libintl.cpp
34 struct kde_loaded_l10nfile
41 kde_loaded_l10nfile() : filename(0), decided(0), data(0) {}
45 class KCataloguePrivate
52 kde_loaded_l10nfile domain;
56 : d( new KCataloguePrivate )
65 TQString path = TQString::fromLatin1(
"%1/LC_MESSAGES/%2.mo")
69 TQString fileName = locate(
"locale", path );
70 if (fileName.isEmpty())
71 fileName = locate(
"locale-bundle", path );
73 setFileName( fileName );
78 : d( new KCataloguePrivate )
85 d->name = rhs.d->name;
86 d->language = rhs.d->language;
87 d->pluralType = rhs.d->pluralType;
88 setFileName( rhs.fileName() );
117 return d->pluralType;
121 void KCatalogue::setFileName(
const TQString & fileName )
124 if ( this->fileName() == fileName )
return;
128 TQCString newFileName = TQFile::encodeName( fileName );
130 if ( !fileName.isEmpty() )
133 char *filename =
new char[ newFileName.length() + 1 ];
134 ::qstrcpy( filename, newFileName );
135 d->domain.filename = filename;
139 TQString KCatalogue::fileName()
const
141 return TQFile::decodeName( d->domain.filename );
146 return ::k_nl_find_msg( &d->domain, msgid );
149 void KCatalogue::doUnload()
152 if ( d->domain.data )
153 ::k_nl_unload_domain( (
struct loaded_domain *)d->domain.data );
157 delete []
const_cast<char *
>(d->domain.filename);
158 d->domain.filename = 0;
160 d->domain.decided = 0;
virtual ~KCatalogue()
Destructor.
TQString name() const
Returns the name of the catalog.
TQString language() const
Returns the language of the catalog.
void setPluralType(int pluralType)
Sets the plural type for the catalog.
This class abstracts a gettext message catalog.
const char * translate(const char *msgid) const
Retrieves a translation of the specified message id.
int pluralType() const
Returns the plural type for the catalog.
KCatalogue & operator=(const KCatalogue &rhs)
Assignment operator.
KCatalogue(const TQString &name=TQString::null, const TQString &language=TQString::null)
Constructor.
const char * name(StdAction id)