299 lines
8.9 KiB
Diff
299 lines
8.9 KiB
Diff
Index: src/bookmarks/ephy-bookmarks-import.c
|
|
===================================================================
|
|
--- src/bookmarks/ephy-bookmarks-import.c (révision 8368)
|
|
+++ src/bookmarks/ephy-bookmarks-import.c (copie de travail)
|
|
@@ -812,49 +812,65 @@ ephy_bookmarks_import_xbel (EphyBookmark
|
|
return ret >= 0 ? TRUE : FALSE;
|
|
}
|
|
|
|
-#define OLD_RDF_TEMPORARY_HACK
|
|
-
|
|
static void
|
|
-parse_rdf_subjects (xmlNodePtr node,
|
|
- GList **subjects)
|
|
+parse_rdf_lang_tag (xmlNode *child,
|
|
+ xmlChar **value,
|
|
+ int *best_match)
|
|
{
|
|
- xmlChar *subject;
|
|
-
|
|
-#ifdef OLD_RDF_TEMPORARY_HACK
|
|
- xmlNode *child;
|
|
+ const char * const *locales;
|
|
+ char *this_language;
|
|
+ xmlChar *lang;
|
|
+ xmlChar *content;
|
|
+ int i;
|
|
+
|
|
+ if (*best_match == 0)
|
|
+ /* there's no way we can do better */
|
|
+ return;
|
|
+
|
|
+ locales = g_get_language_names ();
|
|
+
|
|
+ content = xmlNodeGetContent (child);
|
|
+ if (!content)
|
|
+ return;
|
|
|
|
- child = node->children;
|
|
-
|
|
- while (child != NULL)
|
|
+ lang = xmlNodeGetLang (child);
|
|
+ if (lang == NULL)
|
|
{
|
|
- if (xmlStrEqual (child->name, (xmlChar *) "Bag"))
|
|
- {
|
|
- child = child->children;
|
|
-
|
|
- while (child != NULL)
|
|
- {
|
|
- if (xmlStrEqual (child->name, (xmlChar *) "li"))
|
|
- {
|
|
- subject = xmlNodeGetContent (child);
|
|
- *subjects = g_list_append (*subjects, subject);
|
|
- }
|
|
+ const char *translated;
|
|
|
|
- child = child->next;
|
|
- }
|
|
+ translated = _((char *) content);
|
|
+ if ((char *) content != translated)
|
|
+ {
|
|
+ /* if we have a translation for the content of the
|
|
+ * node, then we just use this */
|
|
+ if (*value) xmlFree (*value);
|
|
+ *value = (xmlChar *) g_strdup (translated);
|
|
+ *best_match = 0;
|
|
|
|
+ xmlFree (content);
|
|
return;
|
|
}
|
|
|
|
- child = child->next;
|
|
+ this_language = "C";
|
|
}
|
|
-#endif
|
|
+ else
|
|
+ this_language = (char *) lang;
|
|
|
|
- subject = xmlNodeGetContent (node);
|
|
|
|
- if (subject)
|
|
- {
|
|
- *subjects = g_list_append (*subjects, subject);
|
|
+ for (i = 0; locales[i] && i < *best_match; i++) {
|
|
+ if (!strcmp (locales[i], this_language)) {
|
|
+ /* if we've already encountered a less accurate
|
|
+ * translation, then free it */
|
|
+ if (*value) xmlFree (*value);
|
|
+
|
|
+ *value = xmlNodeGetContent (child);
|
|
+ *best_match = i;
|
|
+
|
|
+ break;
|
|
+ }
|
|
}
|
|
+
|
|
+ if (lang) xmlFree (lang);
|
|
}
|
|
|
|
static void
|
|
@@ -862,43 +878,59 @@ parse_rdf_item (EphyBookmarks *bookmarks
|
|
xmlNodePtr node)
|
|
{
|
|
xmlChar *title = NULL;
|
|
+ int best_match_title = INT_MAX;
|
|
xmlChar *link = NULL;
|
|
+ int best_match_link = INT_MAX;
|
|
+ /* we consider that it's better to use a non-localized smart link than
|
|
+ * a localized link */
|
|
+ gboolean use_smartlink = FALSE;
|
|
+ xmlChar *subject = NULL;
|
|
GList *subjects = NULL, *l = NULL;
|
|
xmlNode *child;
|
|
- EphyNode *bmk;
|
|
+ EphyNode *bmk = NULL;
|
|
|
|
child = node->children;
|
|
|
|
-#ifdef OLD_RDF_TEMPORARY_HACK
|
|
link = xmlGetProp (node, (xmlChar *) "about");
|
|
-#endif
|
|
|
|
while (child != NULL)
|
|
{
|
|
if (xmlStrEqual (child->name, (xmlChar *) "title"))
|
|
{
|
|
- title = xmlNodeGetContent (child);
|
|
+ parse_rdf_lang_tag (child, &title, &best_match_title);
|
|
}
|
|
-#ifndef OLD_RDF_TEMPORARY_HACK
|
|
- else if (xmlStrEqual (child->name, (xmlChar *) "link"))
|
|
+ else if (xmlStrEqual (child->name, (xmlChar *) "link") &&
|
|
+ !use_smartlink)
|
|
{
|
|
- link = xmlNodeGetContent (child);
|
|
+ parse_rdf_lang_tag (child, &link, &best_match_link);
|
|
}
|
|
-#endif
|
|
- else if (xmlStrEqual (child->name, (xmlChar *) "subject"))
|
|
+ else if (child->ns &&
|
|
+ xmlStrEqual (child->ns->prefix, (xmlChar *) "ephy") &&
|
|
+ xmlStrEqual (child->name, (xmlChar *) "smartlink"))
|
|
{
|
|
- parse_rdf_subjects (child, &subjects);
|
|
+ if (!use_smartlink)
|
|
+ {
|
|
+ use_smartlink = TRUE;
|
|
+ best_match_link = INT_MAX;
|
|
+ }
|
|
+
|
|
+ parse_rdf_lang_tag (child, &link, &best_match_link);
|
|
}
|
|
- else if (xmlStrEqual (child->name, (xmlChar *) "smartlink"))
|
|
+ else if (child->ns &&
|
|
+ xmlStrEqual (child->ns->prefix, (xmlChar *) "dc") &&
|
|
+ xmlStrEqual (child->name, (xmlChar *) "subject"))
|
|
{
|
|
- if (link) xmlFree (link);
|
|
- link = xmlNodeGetContent (child);
|
|
+ subject = xmlNodeGetContent (child);
|
|
+ if (subject)
|
|
+ subjects = g_list_prepend (subjects, subject);
|
|
}
|
|
|
|
child = child->next;
|
|
}
|
|
|
|
- bmk = bookmark_add (bookmarks, (char *) title, (char *) link);
|
|
+ if (title && link)
|
|
+ bmk = bookmark_add (bookmarks, (char *) title, (char *) link);
|
|
+
|
|
if (bmk)
|
|
{
|
|
l = subjects;
|
|
Index: src/bookmarks/Makefile.am
|
|
===================================================================
|
|
--- src/bookmarks/Makefile.am (révision 8368)
|
|
+++ src/bookmarks/Makefile.am (copie de travail)
|
|
@@ -107,6 +107,7 @@ libephybookmarks_la_CPPFLAGS = \
|
|
-I$(top_srcdir)/embed \
|
|
-I$(top_srcdir)/lib/widgets \
|
|
-I$(top_srcdir)/lib/egg \
|
|
+ -DDATADIR=\""$(pkgdatadir)"\" \
|
|
$(AM_CPPFLAGS)
|
|
|
|
libephybookmarks_la_CFLAGS = \
|
|
Index: src/bookmarks/ephy-bookmarks.c
|
|
===================================================================
|
|
--- src/bookmarks/ephy-bookmarks.c (révision 8368)
|
|
+++ src/bookmarks/ephy-bookmarks.c (copie de travail)
|
|
@@ -101,15 +101,6 @@ typedef struct
|
|
const char *location;
|
|
} EphyBookmarksBookmarkInfo;
|
|
|
|
-static const EphyBookmarksBookmarkInfo default_bookmarks [] =
|
|
-{
|
|
- /* Translators you should change these links to respect your locale.
|
|
- * For instance in .nl these should be
|
|
- * "http://www.google.nl" and "http://www.google.nl/search?q=%s"
|
|
- */
|
|
- { N_("Search the web"), N_("http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8") }
|
|
-};
|
|
-
|
|
static const char *default_topics [] =
|
|
{
|
|
N_("Entertainment"),
|
|
@@ -151,13 +142,7 @@ ephy_bookmarks_init_defaults (EphyBookma
|
|
ephy_bookmarks_add_keyword (eb, _(default_topics[i]));
|
|
}
|
|
|
|
- for (i = 0; i < G_N_ELEMENTS (default_bookmarks); i++)
|
|
- {
|
|
- EphyNode *bmk;
|
|
-
|
|
- bmk = ephy_bookmarks_add (eb, _(default_bookmarks[i].title),
|
|
- _(default_bookmarks[i].location));
|
|
- }
|
|
+ ephy_bookmarks_import_rdf (eb, DATADIR "/default-bookmarks.rdf");
|
|
}
|
|
|
|
static void
|
|
Index: data/default-bookmarks.rdf.xml.in
|
|
===================================================================
|
|
--- data/default-bookmarks.rdf.xml.in (révision 0)
|
|
+++ data/default-bookmarks.rdf.xml.in (révision 0)
|
|
@@ -0,0 +1,23 @@
|
|
+<?xml version="1.0"?>
|
|
+<rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ephy="http://gnome.org/ns/epiphany#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
|
+ <channel rdf:about="file://@pkgdatadir@/bookmarks.rdf">
|
|
+ <title>Epiphany bookmarks</title>
|
|
+ <link>http://www.gnome.org/projects/epiphany/</link>
|
|
+ <items>
|
|
+ <rdf:Seq>
|
|
+ <rdf:li rdf:resource="http://www.google.com"/>
|
|
+ </rdf:Seq>
|
|
+ </items>
|
|
+ </channel>
|
|
+ <item rdf:about="http://www.google.com">
|
|
+ <_title>Search the web</_title>
|
|
+ <!-- Translators you should change these links to respect your locale.
|
|
+ For instance in .nl these should be
|
|
+ "http://www.google.nl" and "http://www.google.nl/search?q=%s" -->
|
|
+ <_link>http://www.google.com</_link>
|
|
+ <!-- Translators you should change these links to respect your locale.
|
|
+ For instance in .nl these should be
|
|
+ "http://www.google.nl" and "http://www.google.nl/search?q=%s" -->
|
|
+ <_ephy:smartlink>http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8</_ephy:smartlink>
|
|
+ </item>
|
|
+</rdf:RDF>
|
|
Index: data/Makefile.am
|
|
===================================================================
|
|
--- data/Makefile.am (révision 8368)
|
|
+++ data/Makefile.am (copie de travail)
|
|
@@ -60,6 +60,17 @@ service_DATA = $(service_in_files:.servi
|
|
$(service_DATA): $(service_in_files) Makefile
|
|
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
|
|
|
+# Default bookmarks
|
|
+# intltool hack: we name the file .xml.in so that intltool knows it's xml
|
|
+# format and can analyze it.
|
|
+# We don't put translations in the resulting rdf since the code can get
|
|
+# the translations via gettext (although it can also get translations
|
|
+# from the rdf if they are there and not available via gettext)
|
|
+default_bookmarksdir = $(pkgdatadir)
|
|
+default_bookmarks_in_files = default-bookmarks.rdf.xml.in
|
|
+default_bookmarks_DATA = $(default_bookmarks_in_files:.rdf.xml.in=.rdf)
|
|
+$(default_bookmarks_DATA): $(default_bookmarks_in_files) Makefile
|
|
+ @sed -e "s|\@pkgdatadir\@|$(pkgdatadir)|;s|_title|title|g;s|_link|link|g;s|_ephy:smartlink|ephy:smartlink|g" $< > $@
|
|
|
|
install-data-local: $(schema_DATA)
|
|
if GCONF_SCHEMAS_INSTALL
|
|
@@ -83,6 +94,7 @@ EXTRA_DIST = \
|
|
$(xsl_DATA) \
|
|
$(service_DATA) \
|
|
$(m4data_DATA) \
|
|
+ $(default_bookmarks_in_files) \
|
|
epiphany-service.xml \
|
|
check-mime.py \
|
|
generate-font-schemas.py
|
|
@@ -92,4 +104,5 @@ DISTCLEANFILES = \
|
|
$(schema_in_files:.schemas.in=.schemas) \
|
|
$(pkgconfig_DATA) \
|
|
$(default_prefs_DATA) \
|
|
- $(desktop_DATA)
|
|
+ $(desktop_DATA) \
|
|
+ $(default_bookmarks_DATA)
|
|
Index: po/POTFILES.in
|
|
===================================================================
|
|
--- po/POTFILES.in (révision 8368)
|
|
+++ po/POTFILES.in (copie de travail)
|
|
@@ -2,6 +2,7 @@
|
|
# List of source files containing translatable strings.
|
|
# Please keep this file sorted alphabetically.
|
|
data/bme.desktop.in.in
|
|
+data/default-bookmarks.rdf.xml.in
|
|
data/epiphany.desktop.in.in
|
|
data/epiphany-lockdown.schemas.in
|
|
data/epiphany.schemas.in
|