Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 16 Mar 2015 11:18:46 +0700
From: Рысь <lynx@...server.ru>
To: musl@...ts.openwall.com
Subject: Re: libintl: stubs or working functions?

On Sun, 15 Mar 2015 19:54:18 -0400
Rich Felker <dalias@...c.org> wrote:

> On Sun, Mar 15, 2015 at 07:33:39PM +0700, Рысь wrote:
> > Ok, for now I am probably stuck with this one, it needs much of
> > reading from endless strace logs for various gtkware. I got it to
> > include *gettext syms and now gtk stack calls them, but that's a
> > dead end: even if I set all LC_/LANG properly I still get English
> > and my debugging musl which have locale functions with inserted
> > printfs at beginning show only setlocale(0, "") and that's all.
> > Only few called with proper arguments. I see .mo's from proper path
> > (containing name of desired locale, thus = "*/ru/*") are mmaped.
> > 
> > As for now I have no much time to test it (likely I will continue on
> > this one in next month or so), so I only want to resolve one issue
> > which still stays: is it permitted to change strftime in a way that
> > "%x" will return NOT American date with month in beginning, but
> > preferred date like "%d.%m.%Y" or similar? Will not it break any
> > existing apps?
> 
> I'm not aware one way or the other whether it would break existing
> applications for strftime to format %x in a non-conforming way for the
> C locale. It's certainly possible that this could break apps, since
> the C standard specifies an exact date/time format for the C locale,
> but it's probably not extremely likely.
> 
> To achieve this with a locale (which should not break anything), you
> would just need to make a po file that maps the string "%m/%d/%y" to
> "%d.%m.%Y" or similar, build this into a .mo file named "ru_RU" (with
> no extension), and drop it into a directory in $MUSL_LOCPATH (which
> you should set). Then LC_DATE=ru_RU would give your desired
> formatting.
> 
> This ru_RU locale file could also be extended with translations for
> error messages, mappings for other date/time formats, etc.
> 
> Rich

Hm, I tried this now but without success :-(

I searched for po file layout and I assume this is something like this:

% cat ru_RU.po                                                                                     

# strftime %x
msgid "%m/%d/%y"
msgstr "%d.%m.%Y"

then, I do translate it into .mo file without extension:

% mkdir ru
% msgfmt ru_RU.po -o ru/ru_RU
% file ru/ru_RU
ru/ru_RU: GNU-format message catalog data
% strings -a ru/ru_RU
%m/%d/%y
%d.%m.%Y

I have this test program:

% cat dt.c                                                                                         
#include <time.h>
#include <stdio.h>

int main(void)
{
	char x[32];
	struct tm *tm;
	time_t t;

	t = time(NULL);
	tm = localtime(&t);
	strftime(x, sizeof(x), "%x", tm);
	printf("%s\n", x);

	return 0;
}

(compile it as usual)

and not, with MUSL_LOCPATH=$(pwd)/ru LC_DATE=ru_RU ./dt, I still see
03/16/15.

Not even with LC_TIME and LC_ALL/LANG pair.

I attach strace log, but it probably useless, it only shows no files
are included. Same with musl from git (I currently on musl 1.1.4).

Am I completely messed something?

Download attachment "dt.log" of type "application/octet-stream" (752 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.