Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed

  • Loading branch information...
commit 754f51ff5a5440df1df4e6da1c6cf11ddd0f02ba 1 parent f2c4b43
@aberlanas authored
Showing with 34 additions and 56 deletions.
  1. +1 −1  Makefile
  2. +33 −55 po-thumbnailer.c
View
2  Makefile
@@ -1,6 +1,6 @@
po-thumbnailer: po-thumbnailer.o
- c++ po-thumbnailer.o -o po-thumbnailer -pthread -lgtkmm-2.4 -lcairo
+ c++ po-thumbnailer.o -o po-thumbnailer -pthread -lgtkmm-2.4 -lglibmm-2.4 -lgobject-2.0 -lgio-2.0 -lcairomm-1.0 -lgettextpo
#linking done
po-thumbnailer.o: po-thumbnailer.c
c++ -Wall -c po-thumbnailer.c -o po-thumbnailer.o `pkg-config --cflags gtkmm-2.4 glibmm-2.4`
View
88 po-thumbnailer.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include<stdlib.h>
#include <gdkmm-2.4/gdkmm.h>
+#include <gettext-po.h>
#include <string>
#include <iostream>
@@ -20,6 +21,8 @@ static const GOptionEntry goption_options[] = {
{ NULL }
};
+
+
void create_pie(int size,int translated,int fuzzy, int untranslated,const char* file_name)
{
@@ -121,71 +124,45 @@ void create_pie(int size,int translated,int fuzzy, int untranslated,const char*
}
-
+
-int* capture_msgfmt_output(const char *file)
+int* parse_po(const char *file)
{
+ po_file_t po;
+ po_xerror_handler_t error_handle=(po_xerror_handler_t) malloc (sizeof (po_xerror_handler_t));
+ static int output[4]={0,0,0,0};
- string data;
- static int output[4]={0,0,0,0};
-
-
- dup2(STDOUT_FILENO,STDERR_FILENO);
- FILE * stream;
- char cmd[256]="LANG=C msgfmt --statistics \"";
- strcat(cmd,file);
- strcat(cmd,"\" 2>&1");
- cout << cmd << endl;
- stream=popen(cmd,"r");
-
- char buffer[256];
-
- while(!feof(stream))
- if(fgets(buffer,256,stream)!=NULL)
- data.append(buffer);
- pclose(stream);
+ po=po_file_read(file,error_handle);
- char *tmp;
- tmp=strtok((char*)data.c_str(),",");
- while(tmp!=NULL)
+ if(po==NULL)
+ return output;
+
+ po_message_iterator_t it;
+ it = po_message_iterator( po, NULL );
+ po_message_t msg;
+ const char* msgstr;
+ while ((msg=po_next_message(it))!= NULL)
{
-
- if (strstr(tmp," translated message")!=NULL)
+ if (po_message_is_obsolete(msg))
+ output[4]++;
+ else
+ if (po_message_is_fuzzy( msg))
+ output[1]++;
+ else
{
-
- istringstream iss(string(tmp),istringstream::in);
- string tmp_str;
- iss >> tmp_str;
- output[0]=atoi(tmp_str.c_str());
-
+ msgstr = po_message_msgstr( msg );
+ if ( msgstr[0] == '\0' )
+ output[2]++;
+ else
+ output[0]++;
}
-
- if (strstr(tmp," untranslated")!=NULL)
- {
- istringstream iss(string(tmp),istringstream::in);
- string tmp_str;
- iss >> tmp_str;
- output[2]=atoi(tmp_str.c_str());
-
- }
-
- if (strstr(tmp,"fuzzy")!=NULL)
- {
-
- istringstream iss(string(tmp),istringstream::in);
- string tmp_str;
- iss >> tmp_str;
- output[1]=atoi(tmp_str.c_str());
-
- }
-
- tmp=strtok(NULL,",");
-
}
+ po_message_iterator_free(it);
+ po_file_free(po);
return output;
-
+
}
@@ -218,8 +195,9 @@ int main(int argc, char* argv[])
input= g_file_new_for_commandline_arg(file_arguments[0]);
output=g_file_new_for_commandline_arg(file_arguments[1]);
- int* pie_values=capture_msgfmt_output(g_file_get_parse_name(input));
+ int* pie_values=parse_po(g_file_get_parse_name(input));
create_pie(size,pie_values[0],pie_values[1],pie_values[2],g_file_get_parse_name(output));
+
return 0;
}
Please sign in to comment.
Something went wrong with that request. Please try again.