Re: Things Havoc needs..
On Tue, 29 Dec 1998, Jason Gunthorpe wrote:
>
> AFAIK gettext has issues with this. Apparently you are not supposed to put
> strings in libraries. Blah I say.
>
According to people who are supposed to know, what you need to do is use
dgettext() instead of gettext() in libraries, and then the strings are
translated in the application's "domain" whatever that means. I don't
really get it but I think it works somehow.
Here is what the Gnome libraries use:
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (PACKAGE, String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
/* Stubs that do something close enough. */
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define N_(String) (String)
#endif
PACKAGE is defined by each application. This is rumored to work. :-)
Anywhere in the code functions are allowed, surround strings to be
translated with the _() macro, like _("translate me"). If functions aren't
syntactically permitted, you use N_("translate me") instead.
The only big "gotcha" is that you can't construct phrases with
concatenation. i.e. you can't do this:
string s = _("This is a ");
s += some_variable;
s += _(" which does foo.");
because this makes assumptions about the syntax of the language. It's
better to use a printf or snprintf format:
snprintf(buf, 255, _("This is a %s which does foo."), some_variable);
Then the translator can translate the phrase as a whole and relocate the
variable as needed.
Vincent may have more insights (I don't know if he's on this list though).
> > - Machine editing of sources.list
>
> Oh um, erm.. I guess so :|
>
Hey, you asked. ;-)
I was thinking about how to do this; how about:
To save vector<sources.list entries> -
Iterate over each line in sources.list
If it's a comment ignore it
If it's an entry - if it's in the vector, remove it from the vector
if it's not, remove it from sources.list
When you get to the end of sources.list, append whatever's left in
the vector.
Leaves comments and unchanged entries as they are.
Maybe it's more convenient to implement by just comparing two
pkgSourceList (old and new) to generate a "diff" and then apply that to
the file...
Does that solve the annoying part, or is there something else yucky about
it?
> > - "Cancel" feature for download dialog
>
> This I think can be done easially.. I'd like to wait till I can test it
> thought..
>
No problem.
> > - For the Import/Export package list items, I'm not really sure what
> > the implementation involves. Maybe it will involve apt-pkg.
> > I haven't thought about it.
>
> I'm not sure what these were to do, wasn't it just a list of selected
> packages?
>
Uh... let's ask Wichert. :-)
> > - I still haven't written the "extract list of sections" function,
> > perhaps this should be part of the cache?
>
> Not sure, it is fairly easy to generate from the current data - I guess it
> depends on what you are doing.
>
Yeah, it's easy. I'm going to add it to my cache wrapper if it's not in
the library. It's used to generate the list of categories if you group by
section, and to generate the section filter menu.
I was thinking there might be an optimization if the cache already
iterates over all the packages, then the frontend wouldn't have to do so
again. However, iteration is fast and I have to do it all the time anyway
to maintain the display so it doesn't really matter.
> > - I kind of feel that "Package Status" should be a library thing.
> > I randomly invented some status categories, but I think it would
> > make sense for apt-get and any future frontends to use the same ones.
> > This code (along with lots of other dubious code, often I don't
> > know what the hell I'm doing when I move out of gnome-land :-) can be
> > found in pkgutil.cc.
>
> What is Package Status?
>
What to show in the "Status" field for each package. What I have now is:
Util::StatusType
Util::status_type(pkgCache::PkgIterator & i, GAptCache* cache)
{
pkgDepCache::StateCache & state = (*cache)[i];
if (state.NowBroken()) return StatusNowBroken;
else if (state.InstBroken()) return StatusInstBroken;
else if (state.NewInstall()) return StatusNewInstall;
else if (state.Upgrade()) return StatusUpgrade;
else if (state.Downgrade()) return StatusDowngrade;
else if (state.Delete()) return StatusDelete;
else if (state.Install()) return StatusInstall;
else if (state.Status == 2) return StatusNotInstalled;
else if (state.Keep()) return StatusKept;
else if (state.Held()) return StatusHeld;
else return StatusTypeEnd;
}
The order is important, later items assume earlier items were already
false.
Hope some of this is helpful,
Havoc
Reply to: