Home | History | Annotate | Download | only in localize
      1 #include <cstdio>
      2 #include "merge_res_and_xliff.h"
      3 #include <stdio.h>
      4 
      5 int
      6 merge_test()
      7 {
      8     Configuration english;
      9         english.locale = "en_US";
     10     Configuration translated;
     11         translated.locale = "zz_ZZ";
     12 
     13     ValuesFile* en_current = ValuesFile::ParseFile("testdata/merge_en_current.xml", english,
     14                                                     CURRENT_VERSION, "3");
     15     if (en_current == NULL) {
     16         fprintf(stderr, "merge_test: unable to read testdata/merge_en_current.xml\n");
     17         return 1;
     18     }
     19 
     20     ValuesFile* xx_current = ValuesFile::ParseFile("testdata/merge_xx_current.xml", translated,
     21                                                     CURRENT_VERSION, "3");
     22     if (xx_current == NULL) {
     23         fprintf(stderr, "merge_test: unable to read testdata/merge_xx_current.xml\n");
     24         return 1;
     25     }
     26     ValuesFile* xx_old = ValuesFile::ParseFile("testdata/merge_xx_old.xml", translated,
     27                                                     OLD_VERSION, "2");
     28     if (xx_old == NULL) {
     29         fprintf(stderr, "merge_test: unable to read testdata/merge_xx_old.xml\n");
     30         return 1;
     31     }
     32 
     33     XLIFFFile* xliff = XLIFFFile::Parse("testdata/merge.xliff");
     34 
     35     ValuesFile* result = merge_res_and_xliff(en_current, xx_current, xx_old,
     36                                 "//device/tools/localize/testdata/res/values/strings.xml", xliff);
     37 
     38     if (result == NULL) {
     39         fprintf(stderr, "merge_test: result is NULL\n");
     40         return 1;
     41     }
     42 
     43     printf("======= RESULT =======\n%s===============\n", result->ToString().c_str());
     44 
     45     return 0;
     46 }
     47 
     48 
     49