After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 704021 - (de)serializazion method restores and saves localized location names
(de)serializazion method restores and saves localized location names
Status: RESOLVED OBSOLETE
Product: libgweather
Classification: Core
Component: general
3.9.x
Other Linux
: Normal normal
: future
Assigned To: libgweather-maint
libgweather-maint
3.10
Depends on:
Blocks:
 
 
Reported: 2013-07-11 17:15 UTC by Evgeny Bobkin
Modified: 2021-06-09 21:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screenshot illustration a resulting locale mismatch due to broken serialization (114.59 KB, image/png)
2013-07-28 13:02 UTC, Evgeny Bobkin
  Details
patch proposal (6.23 KB, patch)
2013-07-28 14:51 UTC, Evgeny Bobkin
committed Details | Review

Description Evgeny Bobkin 2013-07-11 17:15:56 UTC
This could not be correct, as the save by serialization localized name cannot be used to identify location based on this data. 

There is a bug in gnome-clocks:
 
start gnome-clock, add a Boston city to world clocks 
close the app
start it in a different locale: LANG=ru_RU.UTF-8 gnome-clocks
The name boston will be displayed unlocalized.
the name is displayed "Boston, Соединенные Штаты Америки"

and vise versa

if you оpen gnome-clocks in russian locale, and adds the city name in russian like "бостон", closes the app and reopens it in english again, the name of the location is displayed as "Бостон, United States"
Comment 1 Evgeny Bobkin 2013-07-11 17:27:10 UTC
It would be great, if it were possible to obtain a city name in english with the localized one (not in within the same call) when using in other location.

Currently it's only possible to stations, because their name are no localized.

A function to obtain a country name of a location would be great as well.

If a contribution is welcomed, I can make a proposal
Comment 2 Evgeny Bobkin 2013-07-11 17:31:23 UTC
Moreover the current design pattern for obtaining locations and timezones (cp. https://wiki.gnome.org/GnomeOS/Design/Whiteboards/TimeZoneSelection) request the functionality to search in both languages, which is the normal case, every user  using a russian locale expects.
Comment 3 Evgeny Bobkin 2013-07-11 17:40:18 UTC
I already thought, how it could be implemented, my idea for the location database is to merge all single generated locale databases like Location.ru.xml with the english one Location.xml. In the all in one case there is nothing to do.
Comment 4 Giovanni Campagna 2013-07-13 16:00:17 UTC
So...

for what concerns the serialization format, it was meant to store the name explicitly so that you could customize the name from the UI.
Also, it was meant to store "detached" locations, ie locations not in the db but created for example from geocode-glib data. In the end, this was never implemented, but it could be.
Indeed, the app could just build the serialization format itself after talking to geocode-glib, if it doesn't mind the instability of libgweather.

For the other issue, that is, the search in both languages, I believe the easiest solution would be to drop the translated databases completely. Instead, we would have the Locations.xml in English, we would look up the translation while parsing with regular gettext from the libgweather-locations catalog.
The problem is, gettext doesn't really like two domains the same project, so I don't know the build stuff required to make it work.
Comment 5 Evgeny Bobkin 2013-07-18 13:45:28 UTC
(In reply to comment #4)
> So...
> 
> for what concerns the serialization format, it was meant to store the name
> explicitly so that you could customize the name from the UI.
> Also, it was meant to store "detached" locations, ie locations not in the db
> but created for example from geocode-glib data. In the end, this was never
> implemented, but it could be.
Is it still desired? geocode-glib have its own location and place classes already.
> Indeed, the app could just build the serialization format itself after talking
> to geocode-glib, if it doesn't mind the instability of libgweather.
> 
> For the other issue, that is, the search in both languages, I believe the
> easiest solution would be to drop the translated databases completely. Instead,
> we would have the Locations.xml in English, we would look up the translation
> while parsing with regular gettext from the libgweather-locations catalog.
> The problem is, gettext doesn't really like two domains the same project, so I
> don't know the build stuff required to make it work.
one could just change location structure 

struct _GWeatherLocation {
    char **names or Glist names;

to store the names (in order or with locate name string) and parse almost the same way it's now
it will just require to modify the parser function 
char *
gweather_parser_get_localized_value (GWeatherParser *parser)
 
What do you think of the following feature, this would not break the existing api
the localized names could be retrieved using the same function
gweather_location_get_name(loc) which would return the locations name according to the current locale setting like:

old_locale = g_strdup (setlocale(LC_MESSAGES, NULL));
setlocale (LC_MESSAGES, "en_GB.UTF-8");

name = gweather_location_get_name(loc); // would give "Moscow"

setlocale (LC_MESSAGES, "de_DE.UTF-8"); 
name = gweather_location_get_name(loc); // "Moskau"

setlocale (LC_MESSAGES, "ru_RU.UTF-8"); 
name = gweather_location_get_name(loc); // "Москва" 

and so on, and if not found NULL is returned.
Comment 6 Evgeny Bobkin 2013-07-28 10:15:35 UTC
 amazing, I have seen your recent  changes, so it's now possible to use translation dynamically.
this is definetly the way to go!
Comment 7 Evgeny Bobkin 2013-07-28 13:02:44 UTC
Created attachment 250298 [details]
screenshot illustration a resulting locale mismatch due to broken serialization
Comment 8 Evgeny Bobkin 2013-07-28 14:22:58 UTC
sadly the current change breaks the localization of names totally, because there are many duplicate names and thus the msgctxt should be used additionally 

the function alone is not enough:
ret = (char*) dgettext ("libgweather-locations", (char*) untranslated_value);
Comment 9 Evgeny Bobkin 2013-07-28 14:51:56 UTC
Created attachment 250306 [details] [review]
patch proposal
Comment 10 Giovanni Campagna 2013-07-28 19:27:06 UTC
Review of attachment 250306 [details] [review]:

I guess it makes sense.
Comment 11 Evgeny Bobkin 2013-07-28 19:39:27 UTC
(In reply to comment #10)
> Review of attachment 250306 [details] [review]:
> 
> I guess it makes sense.

-This way only the serialization can be fixed, because name is saved in english only as written in the location.xml
can I by the way push https://bugzilla.gnome.org/show_bug.cgi?id=585766

-the name in any supported localization can be obtained dynamically
 We wish this feature for clocks because we want to support city images later shared on flickr. and It would be appropriate to use the naming convention like berlin-germany.day.jpg, may be also useful for the weather app it could also share images of a city by rain sunshine and so on :-)

-the location-entry can be enhanced with two languages support as now required by current design (cp. Allans design mockup)
Comment 12 Evgeny Bobkin 2013-07-28 19:40:25 UTC
-minus "only" :-) only is a bit strong:-)
Comment 13 GNOME Infrastructure Team 2021-06-09 21:06:04 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/libgweather/-/issues/119.