[gthumb: 24/57] [webalbums] added support for translatable strings.



commit 5308c346a9b8014969e2fa50c85f3ea02b9a22e5
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Jun 13 17:31:30 2010 +0200

    [webalbums] added support for translatable strings.

 extensions/webalbums/albumtheme-private.c          |   10 ++--
 extensions/webalbums/albumtheme-private.h          |    2 +-
 extensions/webalbums/albumtheme.l                  |   24 ++++++-----
 extensions/webalbums/albumtheme.y                  |   43 +++++++++-----------
 .../webalbums/data/albumthemes/Classic/style.css   |   19 +-------
 .../data/albumthemes/ClassicClips/image.gthtml     |   12 +++---
 .../data/albumthemes/ClassicClips/index.gthtml     |    8 ++--
 .../data/albumthemes/ClassicClips/thumbnail.gthtml |    2 +-
 extensions/webalbums/data/albumthemes/text.h       |   20 ++-------
 extensions/webalbums/gth-web-exporter.c            |   27 +++++++-----
 10 files changed, 73 insertions(+), 94 deletions(-)
---
diff --git a/extensions/webalbums/albumtheme-private.c b/extensions/webalbums/albumtheme-private.c
index 8a5636c..6122783 100644
--- a/extensions/webalbums/albumtheme-private.c
+++ b/extensions/webalbums/albumtheme-private.c
@@ -283,7 +283,7 @@ gth_expr_pop (GthExpr *e)
 }
 
 
-GthCell*
+GthCell *
 gth_expr_get_pos (GthExpr *e, int pos)
 {
 	if ((pos <= 0) || (pos > e->top))
@@ -292,7 +292,7 @@ gth_expr_get_pos (GthExpr *e, int pos)
 }
 
 
-GthCell*
+GthCell *
 gth_expr_get (GthExpr *e)
 {
 	return gth_expr_get_pos (e, e->top);
@@ -531,7 +531,7 @@ gth_var_new_expression (const char *name,
 
 GthVar*
 gth_var_new_string (const char *name,
-                   const char *string)
+                    const char *string)
 {
 	GthVar *var;
 
@@ -778,8 +778,8 @@ gth_tag_get_type_from_name (const char *tag_name)
 		return GTH_TAG_THUMBNAILS;
 	else if (g_str_equal (tag_name, "timestamp"))
 		return GTH_TAG_TIMESTAMP;
-	else if (g_str_equal (tag_name, "text"))
-		return GTH_TAG_TEXT;
+	else if (g_str_equal (tag_name, "translate"))
+		return GTH_TAG_TRANSLATE;
 	else if (g_str_equal (tag_name, "html"))
 		return GTH_TAG_HTML;
 	else if (g_str_equal (tag_name, "set_var"))
diff --git a/extensions/webalbums/albumtheme-private.h b/extensions/webalbums/albumtheme-private.h
index d989bf8..ab4ca3f 100644
--- a/extensions/webalbums/albumtheme-private.h
+++ b/extensions/webalbums/albumtheme-private.h
@@ -177,7 +177,7 @@ typedef enum {
 	GTH_TAG_PAGES,
 	GTH_TAG_THUMBNAILS,
 	GTH_TAG_TIMESTAMP,
-	GTH_TAG_TEXT,
+	GTH_TAG_TRANSLATE,
 	GTH_TAG_HTML,
 	GTH_TAG_SET_VAR,
 	GTH_TAG_EVAL,
diff --git a/extensions/webalbums/albumtheme.l b/extensions/webalbums/albumtheme.l
index cf3c70f..f793cb2 100644
--- a/extensions/webalbums/albumtheme.l
+++ b/extensions/webalbums/albumtheme.l
@@ -38,9 +38,9 @@ GFileInputStream *yy_istream;
 number           [0-9]+
 attribute_name   [a-zA-Z_][a-zA-Z_0-9:\.-]*
 name             [a-zA-Z_][^'" \t\n]*
-quote_sign       ['"]
+string           [^']*
 
-%x FUNCTION ATTRIBUTES CONDITION QUOTE
+%x FUNCTION ATTRIBUTES CONDITION QUOTE STRING
 
 %%
 
@@ -63,7 +63,7 @@ quote_sign       ['"]
 "<% set_var"		 	{
 					BEGIN (ATTRIBUTES);
 					return SET_VAR;
-				}	
+				}
 "<% for_each_thumbnail_caption"	{
 					BEGIN (ATTRIBUTES);
 					yylval.ivalue = GTH_TAG_FOR_EACH_THUMBNAIL_CAPTION;
@@ -78,19 +78,23 @@ quote_sign       ['"]
 					yylval.text = g_strdup (yytext);
 					return FUNCTION_NAME;
 				}
-"<%text"                        {
+<ATTRIBUTES>"'"			{
+					BEGIN (STRING);
+					return '\'';
+				}
+<STRING>"'"			{
 					BEGIN (ATTRIBUTES);
-					return BEGIN_TEXT_TAG;
+					return '\'';
 				}
-"<%/text>"		        {
-					BEGIN (INITIAL);
-					return END_TEXT_TAG;
+<STRING>{string}		{
+					yylval.text = g_strdup (yytext);
+					return QUOTED_STRING;
 				}
-<ATTRIBUTES>{quote_sign} 	{
+<ATTRIBUTES>"\""		{
 					BEGIN (QUOTE);
 					return '"';
 				}
-<QUOTE>{quote_sign}		{
+<QUOTE>"\""			{
 					BEGIN (ATTRIBUTES);
 					return '"';
 				}
diff --git a/extensions/webalbums/albumtheme.y b/extensions/webalbums/albumtheme.y
index da5308b..b01957f 100644
--- a/extensions/webalbums/albumtheme.y
+++ b/extensions/webalbums/albumtheme.y
@@ -45,9 +45,9 @@ int   gth_albumtheme_yywrap  (void);
 	GthLoop      *loop;
 }
 
-%nonassoc       IF ELSE ELSE_IF END END_TEXT_TAG FOR_EACH_THUMBNAIL_CAPTION SET_VAR 
-%token          BEGIN_TAG END_TAG BEGIN_TEXT_TAG 
-%token <text>   QUOTED_NAME ATTRIBUTE_NAME FUNCTION_NAME
+%nonassoc       IF ELSE ELSE_IF END END_TEXT_TAG FOR_EACH_THUMBNAIL_CAPTION SET_VAR
+%token          BEGIN_TAG END_TAG BEGIN_TEXT_TAG
+%token <text>   QUOTED_NAME ATTRIBUTE_NAME FUNCTION_NAME QUOTED_STRING
 %token <ivalue> FOR_EACH
 %token <ivalue> NUMBER
 %token <ivalue> HEADER FOOTER
@@ -78,7 +78,6 @@ int   gth_albumtheme_yywrap  (void);
 
 %type <list>   document
 %type <tag>    gthumb_tag
-%type <tag>    gthumb_text_tag
 %type <loop>   gthumb_loop
 %type <cond>   gthumb_if
 %type <cond>   gthumb_else_if
@@ -135,18 +134,6 @@ document	: HTML document {
 			$$ = g_list_prepend ($6, tag);
 		}
 
-		| gthumb_text_tag HTML END_TEXT_TAG document {
-			GthTag *tag;
-			GList  *child_doc;
-			
-			tag = gth_tag_new_html ($2);
-			child_doc = g_list_append (NULL, tag);
-			gth_tag_add_document ($1, child_doc);
-			$$ = g_list_prepend ($4, $1);
-			
-			g_free ($2);
-		}
-
 		| /* empty */ {
 			$$ = NULL;
 		}
@@ -321,17 +308,25 @@ expr		: '(' expr ')' {
 		}
 		;
 
-gthumb_text_tag	: BEGIN_TEXT_TAG attribute_list END_TAG {
-			$$ = gth_tag_new (GTH_TAG_TEXT, $2);
+gthumb_tag 	: SET_VAR attribute_list END_TAG {
+			$$ = gth_tag_new (GTH_TAG_SET_VAR, $2);
 		}
-		;
-
-gthumb_tag 	: BEGIN_TAG tag_type attribute_list END_TAG {
-			$$ = gth_tag_new ($2, $3);
+		
+		| BEGIN_TAG FUNCTION_NAME '\'' QUOTED_STRING '\'' END_TAG {
+			if (gth_tag_get_type_from_name ($2) == GTH_TAG_TRANSLATE) {
+				GList *arg_list;
+				
+				arg_list = g_list_append (NULL, gth_var_new_string ("text", $4));
+				$$ = gth_tag_new (GTH_TAG_TRANSLATE, arg_list);
+			}
+			else {
+				yyerror ("Wrong function: %s", $2);
+				YYERROR;
+			}
 		}
 		
-		| SET_VAR attribute_list END_TAG {
-			$$ = gth_tag_new (GTH_TAG_SET_VAR, $2);
+		| BEGIN_TAG tag_type attribute_list END_TAG {
+			$$ = gth_tag_new ($2, $3);
 		}
 		;
 
diff --git a/extensions/webalbums/data/albumthemes/Classic/style.css b/extensions/webalbums/data/albumthemes/Classic/style.css
index a5e8eee..db45c89 100644
--- a/extensions/webalbums/data/albumthemes/Classic/style.css
+++ b/extensions/webalbums/data/albumthemes/Classic/style.css
@@ -5,6 +5,7 @@
 body {
 	background-color: #4B4B4B;
 	color: white;
+	font-size: 12px;
 }
 
 span.title {
@@ -21,14 +22,12 @@ span.file_name {
 	font-family: monospace;
 }
 
-span.copyright {
-	font-size: small;
+#footer {
+	font-size: 11px;
 }
 
-
 /* image.gthtml */
 
-
 img.preview {
 	border: solid 2px white;
 }
@@ -60,17 +59,6 @@ span.property_value {
 	color: white;
 }
 
-/* index.gthtml */
-
-td.td_index {
-	color: #969696;
-}
-
-td.td_index span.image_dim {
-	font-weight: bold;
-}
-
-
 /* links */
 
 a:link { 
@@ -90,4 +78,3 @@ a:hover {
 	text-decoration: none;
 	color: #FFD700;
 }
-
diff --git a/extensions/webalbums/data/albumthemes/ClassicClips/image.gthtml b/extensions/webalbums/data/albumthemes/ClassicClips/image.gthtml
index b0ac74f..14b1901 100644
--- a/extensions/webalbums/data/albumthemes/ClassicClips/image.gthtml
+++ b/extensions/webalbums/data/albumthemes/ClassicClips/image.gthtml
@@ -23,14 +23,14 @@
       
       <ul class="navigation-bar">
         <li class="index">
-          <a href="<%= page_link idx_relative="0" image_idx %>" title="Go back to the index">
-            <span>Go back to the index</span>
+          <a href="<%= page_link idx_relative="0" image_idx %>" title="<%= translate 'Go back to the index' %>"">
+            <span><%= translate 'Go back to the index' %></span>
           </a>
         </li>
         <% if image_idx < images  %>
         <li class="next-image">          
-          <a href="<%= image_link idx_relative="+1" %>" title="View the next image">
-            <span>View the next image</span>
+          <a href="<%= image_link idx_relative="+1" %>" title="<%= translate 'View the next image' %>">
+            <span><%= translate 'View the next image' %></span>
           </a>
         </li>
         <% else %>
@@ -42,8 +42,8 @@
         </li>
         <% if image_idx > 1  %>
         <li class="previous-image">          
-          <a href="<%= image_link idx_relative="-1" %>" title="View the previous image">
-            <span>View the previous image</span>
+          <a href="<%= image_link idx_relative="-1" %>" title="<%= translate 'View the previous image' %>">
+            <span><%= translate 'View the previous image' %></span>
           </a>     
         </li>
         <% else %>
diff --git a/extensions/webalbums/data/albumthemes/ClassicClips/index.gthtml b/extensions/webalbums/data/albumthemes/ClassicClips/index.gthtml
index a51d328..95555ad 100644
--- a/extensions/webalbums/data/albumthemes/ClassicClips/index.gthtml
+++ b/extensions/webalbums/data/albumthemes/ClassicClips/index.gthtml
@@ -26,8 +26,8 @@
       <ul class="navigation-bar">
         <% if page_idx < pages %>
         <li class="next-page">
-          <a href="<%= page_link idx_relative="+1" %>" title="View the next page">
-            <span>View the next page</span>
+          <a href="<%= page_link idx_relative="+1" %>" title="<%= translate 'View the next page' %>">
+            <span><%= translate 'View the next page' %></span>
           </a>   
         </li> 
         <% else %>
@@ -39,8 +39,8 @@
         </li>
         <% if page_idx > 1  %>
         <li class="previous-page">          
-          <a href="<%= page_link idx_relative="-1" %>" title="View the previous page">
-            <span>View the previous page</span>
+          <a href="<%= page_link idx_relative="-1" %>" title="<%= translate 'View the previous page' %>">
+            <span><%= translate 'View the previous page' %></span>
           </a>       
         </li>
         <% else %>
diff --git a/extensions/webalbums/data/albumthemes/ClassicClips/thumbnail.gthtml b/extensions/webalbums/data/albumthemes/ClassicClips/thumbnail.gthtml
index cce8d4b..ca52fab 100644
--- a/extensions/webalbums/data/albumthemes/ClassicClips/thumbnail.gthtml
+++ b/extensions/webalbums/data/albumthemes/ClassicClips/thumbnail.gthtml
@@ -7,7 +7,7 @@
           <div class="thumbnail-left">
             <div class="thumbnail-right">
               <div class="thumbnail-image-container">
-                <a class="thumbnail-image" href="<%= image_link %>" title="Click to view the image"><%= image thumbnail %></a>
+                <a class="thumbnail-image" href="<%= image_link %>" title="<%= translate 'Click to view the image' %>"><%= image thumbnail %></a>
               </div>
             </div>
           </div>
diff --git a/extensions/webalbums/data/albumthemes/text.h b/extensions/webalbums/data/albumthemes/text.h
index 9e8220d..194660c 100644
--- a/extensions/webalbums/data/albumthemes/text.h
+++ b/extensions/webalbums/data/albumthemes/text.h
@@ -24,19 +24,9 @@
 #include <glib/gi18n.h>
 
 static char *text[] = {
-	N_("Previous"),
-	N_("Next"),
-	N_("Index"),
-	N_("Image"),
-	N_("Dimensions"),
-	N_("Bytes"),
-	N_("Date"),
-	N_("Exposure time"),
-	N_("Exposure mode"),
-	N_("Flash"),
-	N_("Shutter speed"),
-	N_("Aperture value"),
-	N_("Focal length"),
-	N_("Camera model")
-	N_("pixels")
+	N_("Go back to the index"),
+	N_("View the next image"),
+	N_("View the previous image"),
+	N_("View the next page"),
+	N_("View the previous page")
 }
diff --git a/extensions/webalbums/gth-web-exporter.c b/extensions/webalbums/gth-web-exporter.c
index f2bdec7..08ee51f 100644
--- a/extensions/webalbums/gth-web-exporter.c
+++ b/extensions/webalbums/gth-web-exporter.c
@@ -514,10 +514,19 @@ gth_tag_get_str (GthWebExporter *self,
 
 	for (scan = tag->value.arg_list; scan; scan = scan->next) {
 		GthVar *var = scan->data;
+
 		if (strcmp (var->name, var_name) == 0) {
-			GthCell *cell = gth_expr_get(var->value.expr);
-			if (cell->type == GTH_CELL_TYPE_VAR)
-				return cell->value.var;
+			if (var->type == GTH_VAR_EXPR) {
+				GthCell *cell;
+
+				cell = gth_expr_get (var->value.expr);
+				if (cell->type == GTH_CELL_TYPE_VAR)
+					return cell->value.var;
+			}
+			else if (var->type == GTH_VAR_STRING)
+				return var->value.string;
+			else
+				return NULL;
 		}
 	}
 
@@ -1579,15 +1588,9 @@ gth_parsed_doc_print (GthWebExporter      *self,
 			}
 			break;
 
-		case GTH_TAG_TEXT:
-			if ((tag->value.arg_list == NULL) && (tag->document != NULL)) {
-				GthTag *child = tag->document->data;
-
-				if (child->type != GTH_TAG_HTML)
-					break;
-				line = g_strdup (_(child->value.html));
-				write_markup_escape_line (ostream, line, error);
-			}
+		case GTH_TAG_TRANSLATE:
+			line = g_strdup (_(gth_tag_get_str (self, tag, "text")));
+			write_markup_escape_line (ostream, line, error);
 			break;
 
 		default:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]