#!/usr/bin/php -q | +----------------------------------------------------------------------+ */ if ($argc != 2) { ?> Check for translation error and print statistics You can see an example output for french translation here : http://php.keliglia.com/index_error.htm Feel free to ask me some others checks. Usage: Authors:Yannick Torres /s", "", $en_content); $lang_content = preg_replace("//s", "", $lang_content); $retour = false; // chapter $en_chapter = array(); preg_match_all("//s", $en_content, $match); $en_chapter["xmlid"] = $match[2]; $en_chapter["xmlns"] = $match[4]; $en_chapter["xmlnsxlink"] = $match[6]; $lang_chapter = array(); preg_match_all("//s", $lang_content, $match); $lang_chapter["xmlid"] = $match[2]; $lang_chapter["xmlns"] = $match[4]; $lang_chapter["xmlnsxlink"] = $match[6]; for( $i=0; $i < count($en_chapter["xmlid"]); $i ++ ) { if( $en_chapter["xmlid"][$i] != $lang_chapter["xmlid"][$i] ) { $nb_error['chapter'] ++; $result_error[] = array( "libel" => "Error in chapter, attribut : xmlid", "value_en" => $en_chapter["xmlid"][$i], "value_lang" => $lang_chapter["xmlid"][$i], "type" => "chapter", ); } } for( $i=0; $i < count($en_chapter["xmlns"]); $i ++ ) { if( $en_chapter["xmlns"][$i] != $lang_chapter["xmlns"][$i] ) { $nb_error['chapter'] ++; $result_error[] = array( "libel" => "Error in chapter, attribut : xmlns", "value_en" => $en_chapter["xmlns"][$i], "value_lang" => $lang_chapter["xmlns"][$i], "type" => "chapter", ); } } for( $i=0; $i < count($en_chapter["xmlnsxlink"]); $i ++ ) { if( $en_chapter["xmlnsxlink"][$i] != $lang_chapter["xmlnsxlink"][$i] ) { $nb_error['chapter'] ++; $result_error[] = array( "libel" => "Error in chapter, attribut : xmlns:xlink", "value_en" => $en_chapter["xmlnsxlink"][$i], "value_lang" => $lang_chapter["xmlnsxlink"][$i], "type" => "chapter", ); } } // END : chapter // appendix $en_appendix = array(); preg_match_all("//s", $en_content, $match); $en_appendix["xmlid"] = $match[2]; $en_appendix["xmlns"] = $match[4]; $en_appendix["xmlnsxlink"] = $match[6]; $lang_appendix = array(); preg_match_all("//s", $lang_content, $match); $lang_appendix["xmlid"] = $match[2]; $lang_appendix["xmlns"] = $match[4]; $lang_appendix["xmlnsxlink"] = $match[6]; for( $i=0; $i < count($en_appendix["xmlid"]); $i ++ ) { if( $en_appendix["xmlid"][$i] != $lang_appendix["xmlid"][$i] ) { $nb_error['appendix'] ++; $result_error[] = array( "libel" => "Error in appendix, attribut : xmlid", "value_en" => $en_appendix["xmlid"][$i], "value_lang" => $lang_appendix["xmlid"][$i], "type" => "appendix", ); } } for( $i=0; $i < count($en_appendix["xmlns"]); $i ++ ) { if( $en_appendix["xmlns"][$i] != $lang_appendix["xmlns"][$i] ) { $nb_error['appendix'] ++; $result_error[] = array( "libel" => "Error in appendix, attribut : xmlns", "value_en" => $en_appendix["xmlns"][$i], "value_lang" => $lang_appendix["xmlns"][$i], "type" => "appendix", ); } } for( $i=0; $i < count($en_appendix["xmlnsxlink"]); $i ++ ) { if( $en_appendix["xmlnsxlink"][$i] != $lang_appendix["xmlnsxlink"][$i] ) { $nb_error['appendix'] ++; $result_error[] = array( "libel" => "Error in appendix, attribut : xmlns:xlink", "value_en" => $en_appendix["xmlnsxlink"][$i], "value_lang" => $lang_appendix["xmlnsxlink"][$i], "type" => "appendix", ); } } // END : appendix // qandaentry $en_qandaentry = array(); preg_match_all("//s", $en_content, $match); $en_qandaentry = $match[2]; $lang_qandaentry = array(); preg_match_all("//s", $lang_content, $match); $lang_qandaentry = $match[2]; for( $i=0; $i < count($en_qandaentry); $i ++ ) { if( $en_qandaentry[$i] != $lang_qandaentry[$i] ) { $nb_error['qandaentry'] ++; $result_error[] = array( "libel" => "Error in qandaentry, attribut : xml:id", "value_en" => $en_qandaentry[$i], "value_lang" => $lang_qandaentry[$i], "type" => "qandaentry", ); } } // END : qandaentry // linkend $en_linkend = array(); preg_match_all("//s", $en_content, $match); $en_linkend = $match[3]; $lang_linkend = array(); preg_match_all("//s", $lang_content, $match); $lang_linkend = $match[3]; for( $i=0; $i < count($en_linkend); $i ++ ) { if( isset($lang_linkend[$i]) && $en_linkend[$i] != $lang_linkend[$i] && $en_linkend[$i] != 'somethingelse' ) { $nb_error['link'] ++; $result_error[] = array( "libel" => "Error in link, attribut : linkend $i", "value_en" => $en_linkend[$i], "value_lang" => $lang_linkend[$i], "type" => "link", ); } } // END : linkend // link:href $en_linkhref = array(); preg_match_all("//s", $en_content, $match); $en_linkhref = $match[2]; $lang_linkhref = array(); preg_match_all("//s", $lang_content, $match); $lang_linkhref = $match[2]; for( $i=0; $i < count($en_linkhref); $i ++ ) { if( isset($lang_linkhref[$i]) && $en_linkhref[$i] != $lang_linkhref[$i] ) { $nb_error['link'] ++; $result_error[] = array( "libel" => "Error in link, attribut : linkend", "value_en" => $en_linkhref[$i], "value_lang" => $lang_linkhref[$i], "type" => "link", ); } } // END : link:href // sect1 $en_sect1 = array(); preg_match_all("//s", $en_content, $match); $en_sect1 = $match[2]; $lang_sect1 = array(); preg_match_all("//s", $lang_content, $match); $lang_sect1 = $match[2]; for( $i=0; $i < count($en_sect1); $i ++ ) { if( isset($lang_sect1[$i]) && $en_sect1[$i] != $lang_sect1[$i] ) { $nb_error['sect1'] ++; $result_error[] = array( "libel" => "Error in sect1, attribut : xml:id", "value_en" => $en_sect1[$i], "value_lang" => $lang_sect1[$i], "type" => "sect1", ); } } // END : sect1 // book $en_book = array(); preg_match_all("//s", $en_content, $match); $en_book["xmlid"] = $match[2]; $en_book["xmlns"] = $match[4]; $en_book["xmlnsxlink"] = $match[6]; $lang_book = array(); preg_match_all("//s", $lang_content, $match); $lang_book["xmlid"] = $match[2]; $lang_book["xmlns"] = $match[4]; $lang_book["xmlnsxlink"] = $match[6]; for( $i=0; $i < count($en_book["xmlid"]); $i ++ ) { if( $en_book["xmlid"][$i] != $lang_book["xmlid"][$i] ) { $nb_error['book'] ++; $result_error[] = array( "libel" => "Error in book, attribut : xmlid", "value_en" => $en_book["xmlid"][$i], "value_lang" => $lang_book["xmlid"][$i], "type" => "book", ); } } for( $i=0; $i < count($en_book["xmlns"]); $i ++ ) { if( $en_book["xmlns"][$i] != $lang_book["xmlns"][$i] ) { $nb_error['book'] ++; $result_error[] = array( "libel" => "Error in book, attribut : xmlns", "value_en" => $en_book["xmlns"][$i], "value_lang" => $lang_book["xmlns"][$i], "type" => "book", ); } } for( $i=0; $i < count($en_book["xmlnsxlink"]); $i ++ ) { if( $en_book["xmlnsxlink"][$i] != $lang_book["xmlnsxlink"][$i] ) { $nb_error['book'] ++; $result_error[] = array( "libel" => "Error in book, attribut : xmlns:xlink", "value_en" => $en_book["xmlnsxlink"][$i], "value_lang" => $lang_book["xmlnsxlink"][$i], "type" => "book", ); } } // END : book // preface $en_preface = array(); preg_match_all("//s", $en_content, $match); $en_preface = $match[2]; $lang_preface = array(); preg_match_all("//s", $lang_content, $match); $lang_preface = $match[2]; for( $i=0; $i < count($en_preface); $i ++ ) { if( $en_preface[$i] != $lang_preface[$i] ) { $nb_error['preface'] ++; $result_error[] = array( "libel" => "Error in preface, attribut : xml:id", "value_en" => $en_preface[$i], "value_lang" => $lang_preface[$i], "type" => "preface", ); } } // END : preface // section $en_section = array(); preg_match_all("//s", $en_content, $match); $en_section["xmlid"] = $match[3]; $lang_section = array(); preg_match_all("//s", $lang_content, $match); $lang_section["xmlid"] = $match[3]; for( $i=0; $i < count($en_section["xmlid"]); $i ++ ) { if( $en_section["xmlid"][$i] != $lang_section["xmlid"][$i] ) { $nb_error['section'] ++; $result_error[] = array( "libel" => "Error in section, attribut : xmlid", "value_en" => $en_section["xmlid"][$i], "value_lang" => $lang_section["xmlid"][$i], "type" => "section", ); } } // END : section // varlistentry $en_varlistentry = array(); preg_match_all("//s", $en_content, $match); $en_varlistentry = $match[2]; $lang_varlistentry = array(); preg_match_all("//s", $lang_content, $match); $lang_varlistentry = $match[2]; for( $i=0; $i < count($en_varlistentry); $i ++ ) { if( $en_varlistentry[$i] != $lang_varlistentry[$i] ) { $nb_error['varlistentry'] ++; $result_error[] = array( "libel" => "Error in varlistentry, attribut : xml:id", "value_en" => $en_varlistentry[$i], "value_lang" => $lang_varlistentry[$i], "type" => "varlistentry", ); } } // END : varlistentry // reference $en_reference = array(); preg_match_all("//s", $en_content, $match); $en_reference["xmlid"] = $match[2]; $en_reference["xmlns"] = $match[4]; $lang_reference = array(); preg_match_all("//s", $lang_content, $match); $lang_reference["xmlid"] = $match[2]; $lang_reference["xmlns"] = $match[4]; for( $i=0; $i < count($en_reference["xmlid"]); $i ++ ) { if( $en_reference["xmlid"][$i] != $lang_reference["xmlid"][$i] ) { $nb_error['reference'] ++; $result_error[] = array( "libel" => "Error in reference, attribut : xmlid", "value_en" => $en_reference["xmlid"][$i], "value_lang" => $lang_reference["xmlid"][$i], "type" => "reference", ); } } for( $i=0; $i < count($en_reference["xmlns"]); $i ++ ) { if( $en_reference["xmlns"][$i] != $lang_reference["xmlns"][$i] ) { $nb_error['reference'] ++; $result_error[] = array( "libel" => "Error in reference, attribut : xmlns", "value_en" => $en_reference["xmlns"][$i], "value_lang" => $lang_reference["xmlns"][$i], "type" => "reference", ); } } // END : reference // refentry $en_refentry = array(); preg_match_all("//s", $en_content, $match); $en_refentry["xmlid"] = $match[2]; $en_refentry["xmlns"] = $match[4]; $lang_refentry = array(); preg_match_all("//s", $lang_content, $match); $lang_refentry["xmlid"] = $match[2]; $lang_refentry["xmlns"] = $match[4]; for( $i=0; $i < count($en_refentry["xmlid"]); $i ++ ) { if( $en_refentry["xmlid"][$i] != $lang_refentry["xmlid"][$i] ) { $nb_error['refentry'] ++; $result_error[] = array( "libel" => "Error in refentry, attribut : xmlid", "value_en" => $en_refentry["xmlid"][$i], "value_lang" => $lang_refentry["xmlid"][$i], "type" => "refentry", ); } } for( $i=0; $i < count($en_refentry["xmlns"]); $i ++ ) { if( $en_refentry["xmlns"][$i] != $lang_refentry["xmlns"][$i] ) { $nb_error['refentry'] ++; $result_error[] = array( "libel" => "Error in refentry, attribut : xmlns", "value_en" => $en_refentry["xmlns"][$i], "value_lang" => $lang_refentry["xmlns"][$i], "type" => "refentry", ); } } // END : refentry // refsect1 $en_refsect1 = array(); preg_match_all("//s", $en_content, $match); $en_refsect1 = $match[2]; $lang_refsect1 = array(); preg_match_all("//s", $lang_content, $match); $lang_refsect1 = $match[2]; for( $i=0; $i < count($en_refsect1); $i ++ ) { if( isset($lang_refsect1[$i]) && $en_refsect1[$i] != $lang_refsect1[$i] ) { $nb_error['refsect1'] ++; $result_error[] = array( "libel" => "Error in refsect1, attribut : xml:id", "value_en" => $en_refsect1[$i], "value_lang" => $lang_refsect1[$i], "type" => "refsect1", ); } } // END : refsect1 // methodsynopsis $en_methodsynopsis = array(); preg_match_all("/(\s.*?)<\/methodsynopsis>/s", $en_content, $match); for( $i = 0; $i < count($match[1]); $i++) { preg_match_all("/(.*?)<\/type>(.*?)<\/methodname>/s", $match[1][$i], $match2); if( isset($match2[2][0]) && isset($match2[1][0]) ) { $en_methodsynopsis[$i]['methodname']['name'] = $match2[2][0]; $en_methodsynopsis[$i]['methodname']['type'] = $match2[1][0]; preg_match_all("/(.*?)<\/type>(.*?)<\/parameter><\/methodparam>/s", $match[1][$i], $match2); $en_methodsynopsis[$i]['methodparam']['parameter'] = $match2[8]; $en_methodsynopsis[$i]['methodparam']['type'] = $match2[4]; for( $j=0; $j < count($match2[1]); $j++) { if( trim($match2[1][$j]) == 'choice="opt"' || trim($match2[1][$j]) == "choice='opt'" ) { $en_methodsynopsis[$i]['methodparam']['optionnel'][$j] = 1; } else { $en_methodsynopsis[$i]['methodparam']['optionnel'][$j] = 0; } } for( $j=0; $j < count($match2[5]); $j++) { if( trim($match2[5][$j]) == 'role="reference"' || trim($match2[5][$j]) == "role='reference'" ) { $en_methodsynopsis[$i]['methodparam']['role'][$j] = 1; } else { $en_methodsynopsis[$i]['methodparam']['role'][$j] = 0; } } } } $lang_methodsynopsis = array(); preg_match_all("/(\s.*?)<\/methodsynopsis>/s", $lang_content, $match); for( $i = 0; $i < count($match[1]); $i++) { preg_match_all("/(.*?)<\/type>(.*?)<\/methodname>/s", $match[1][$i], $match2); if( isset($match2[2][0]) && isset($match2[1][0]) ) { $lang_methodsynopsis[$i]['methodname']['name'] = $match2[2][0]; $lang_methodsynopsis[$i]['methodname']['type'] = $match2[1][0]; preg_match_all("/(.*?)<\/type>(.*?)<\/parameter><\/methodparam>/s", $match[1][$i], $match2); $lang_methodsynopsis[$i]['methodparam']['parameter'] = $match2[8]; $lang_methodsynopsis[$i]['methodparam']['type'] = $match2[4]; for( $j=0; $j < count($match2[1]); $j++) { if( trim($match2[1][$j]) == 'choice="opt"' || trim($match2[1][$j]) == "choice='opt'" ) { $lang_methodsynopsis[$i]['methodparam']['optionnel'][$j] = 1; } else { $lang_methodsynopsis[$i]['methodparam']['optionnel'][$j] = 0; } } for( $j=0; $j < count($match2[5]); $j++) { if( trim($match2[5][$j]) == 'role="reference"' ) { $lang_methodsynopsis[$i]['methodparam']['role'][$j] = 1; } else { $lang_methodsynopsis[$i]['methodparam']['role'][$j] = 0; } } } } // Verify for( $i=0; $i < count($en_methodsynopsis); $i++) { if( isset($en_methodsynopsis[$i]['methodname']['name']) ) { if( !isset($lang_methodsynopsis[$i]['methodname']['name']) ) { $lang_methodsynopsis[$i]['methodname']['name'] = ''; } // methodname if( $en_methodsynopsis[$i]['methodname']['name'] != $lang_methodsynopsis[$i]['methodname']['name'] ) { $nb_error['methodsynopsis'] ++; $result_error[] = array( "libel" => "Error in methodsynopsis, methodname :", "value_en" => $en_methodsynopsis[$i]['methodname']['name'], "value_lang" => $lang_methodsynopsis[$i]['methodname']['name'], "type" => "methodsynopsis_methodname", ); } } if( isset($en_methodsynopsis[$i]['methodname']['type']) ) { if( !isset($lang_methodsynopsis[$i]['methodname']['type']) ) { $lang_methodsynopsis[$i]['methodname']['type'] = ''; } if( $en_methodsynopsis[$i]['methodname']['type'] != $lang_methodsynopsis[$i]['methodname']['type'] ) { $nb_error['methodsynopsis'] ++; $result_error[] = array( "libel" => "Error in methodsynopsis, methodname, type :", "value_en" => $en_methodsynopsis[$i]['methodname']['type'], "value_lang" => $lang_methodsynopsis[$i]['methodname']['type'], "type" => "methodsynopsis_type", ); } } if( isset($en_methodsynopsis[$i]['methodparam']['parameter']) ) { // methodparam if( !isset($en_methodsynopsis[$i]['methodparam']['parameter']) ) { $en_methodsynopsis[$i]['methodparam']['parameter'] = array(); } if( !isset($lang_methodsynopsis[$i]['methodparam']['parameter']) ) { $lang_methodsynopsis[$i]['methodparam']['parameter'] = array(); } if( count($en_methodsynopsis[$i]['methodparam']['parameter']) != count($lang_methodsynopsis[$i]['methodparam']['parameter']) ) { $nb_error['methodsynopsis'] ++; $result_error[] = array( "libel" => "Error : There is ".count($en_methodsynopsis[$i]['methodparam']['parameter'])." methodparam(s) in EN, ".count($lang_methodsynopsis[$i]['methodparam']['parameter'])." in $LANG", "value_en" => "N/A", "value_lang" => "N/A", "type" => "methodsynopsis_methodparam", ); } for( $j = 0; $j < count($en_methodsynopsis[$i]['methodparam']['parameter']); $j++ ) { if( isset($en_methodsynopsis[$i]['methodparam']['parameter'][$j]) ) { if( !isset($lang_methodsynopsis[$i]['methodparam']['parameter'][$j]) ) { $lang_methodsynopsis[$i]['methodparam']['parameter'][$j] = ''; } // parameter name if( $en_methodsynopsis[$i]['methodparam']['parameter'][$j] != $lang_methodsynopsis[$i]['methodparam']['parameter'][$j] ) { $nb_error['methodsynopsis'] ++; $result_error[] = array( "libel" => "Error in methodsynopsis, methodparam, parameter :", "value_en" => $en_methodsynopsis[$i]['methodparam']['parameter'][$j], "value_lang" => $lang_methodsynopsis[$i]['methodparam']['parameter'][$j], "type" => "methodsynopsis_parameter_name", ); } } if( isset($en_methodsynopsis[$i]['methodparam']['type'][$j]) ) { if( !isset($lang_methodsynopsis[$i]['methodparam']['type'][$j]) ) { $lang_methodsynopsis[$i]['methodparam']['type'][$j] = ''; } // parameter type if( $en_methodsynopsis[$i]['methodparam']['type'][$j] != $lang_methodsynopsis[$i]['methodparam']['type'][$j] ) { $nb_error['methodsynopsis'] ++; $result_error[] = array( "libel" => "Error in methodsynopsis, methodparam, type :", "value_en" => $en_methodsynopsis[$i]['methodparam']['type'][$j], "value_lang" => $lang_methodsynopsis[$i]['methodparam']['type'][$j], "type" => "methodsynopsis_parameter_type", ); } } if( isset($en_methodsynopsis[$i]['methodparam']['optionnel'][$j]) ) { if( !isset($lang_methodsynopsis[$i]['methodparam']['optionnel'][$j]) ) { $lang_methodsynopsis[$i]['methodparam']['optionnel'][$j] = ''; } // is optionnel ? if( $en_methodsynopsis[$i]['methodparam']['optionnel'][$j] != $lang_methodsynopsis[$i]['methodparam']['optionnel'][$j] ) { $tmp1 = ($en_methodsynopsis[$i]['methodparam']['optionnel'][$j] == 0)? $en_methodsynopsis[$i]['methodparam']['parameter'][$j]." ISN'T optionnel":$en_methodsynopsis[$i]['methodparam']['parameter'][$j]." IS optionnel (choice=\"opt\")"; $tmp2 = ($lang_methodsynopsis[$i]['methodparam']['optionnel'][$j] == 0)? $lang_methodsynopsis[$i]['methodparam']['parameter'][$j]." ISN'T optionnel":$lang_methodsynopsis[$i]['methodparam']['parameter'][$j]." IS optionnel (choice=\"opt\")"; $nb_error['methodsynopsis'] ++; $result_error[] = array( "libel" => "Error in methodsynopsis, methodparam, is optionnel ?", "value_en" => $tmp1, "value_lang" => $tmp2, "type" => "methodsynopsis_optional", ); } } if( isset($en_methodsynopsis[$i]['methodparam']['role'][$j]) ) { if( !isset($lang_methodsynopsis[$i]['methodparam']['role'][$j]) ) { $lang_methodsynopsis[$i]['methodparam']['role'][$j] = ''; } // is reference ? if( $en_methodsynopsis[$i]['methodparam']['role'][$j] != $lang_methodsynopsis[$i]['methodparam']['role'][$j] ) { $tmp1 = ($en_methodsynopsis[$i]['methodparam']['role'][$j] == 0)? $en_methodsynopsis[$i]['methodparam']['parameter'][$j]." ISN'T reference":$en_methodsynopsis[$i]['methodparam']['parameter'][$j]." IS reference (role=\"reference\")"; $tmp2 = ($lang_methodsynopsis[$i]['methodparam']['role'][$j] == 0)? $lang_methodsynopsis[$i]['methodparam']['parameter'][$j]." ISN'T reference":$lang_methodsynopsis[$i]['methodparam']['parameter'][$j]." IS reference (role=\"reference\")"; $nb_error['methodsynopsis'] ++; $result_error[] = array( "libel" => "Error in methodsynopsis, methodparam, parameter, attribut : role ?", "value_en" => $tmp1, "value_lang" => $tmp2, "type" => "methodsynopsis_reference", ); } } } } } // END : methodsynopsis // Check if there is a space or a point at the end of refpurpose preg_match_all("/.*([^A-Za-z1-9 ])<\/refpurpose>/s", $lang_content, $match2); if( isset($match2[1][0]) ) { if($match2[1][0] == '.') { $nb_error['refpurpose'] ++; $result_error[] = array( "libel" => "WARNING in refpurpose : there is a point at the end of refpurpose.", "value_en" => "N/A", "value_lang" => "N/A", "type" => "refpurpose_space_period", ); } } // END : space or point at the end of refpurpose // SeeAlso section : check member $en_seeAlsoMember = 0; preg_match("/(.*)<\/refsect1>/s", $en_content, $match2); if (isset($match2[1])) { preg_match_all("/(.*?)<\/member>/s", $match2[1], $match3); if (isset($match3[1])) { $en_seeAlsoMember = count($match3[1]); } } $lang_seeAlsoMember = 0; preg_match("/(.*)<\/refsect1>/s", $lang_content, $match2); if (isset($match2[1])) { preg_match_all("/(.*?)<\/member>/s", $match2[1], $match3); if (isset($match3[1])) { $lang_seeAlsoMember = count($match3[1]); } } if( $en_seeAlsoMember != $lang_seeAlsoMember ) { $nb_error['seealsoMember'] ++; $result_error[] = array( "libel" => "Error in seeAlso section : $en_seeAlsoMember member in EN, and $lang_seeAlsoMember member in $LANG.", "value_en" => "N/A", "value_lang" => "N/A", "type" => "seealsoMember", ); } // END : SeeAlso section : check member // CDATA section $en_cdataSection = 0; preg_match_all("//s", $en_content, $match2); $en_cdataSection = count($match2[1]); $lang_cdataSection = 0; preg_match_all("//s", $lang_content, $match2); $lang_cdataSection = count($match2[1]); if( $en_cdataSection != $lang_cdataSection ) { $nb_error['cdata'] ++; $result_error[] = array( "libel" => "Error about CDATA section : $en_cdataSection section in EN, and $lang_cdataSection section in $LANG.", "value_en" => "N/A", "value_lang" => "N/A", "type" => "cdata", ); } // END : CDATA section // classsynopsis $en_classsynopsis = array(); preg_match_all("/(\s.*?)<\/classsynopsis>/s", $en_content, $match); for( $i = 0; $i < count($match[1]); $i++) { preg_match_all("/(.*?)<\/classname><\/ooclass>/s", $match[1][$i], $match2); ( isset($match2[1][0]) ) ? $en_classsynopsis[$i]['ooclass']['classname'] = $match2[1][0] : $en_classsynopsis[$i]['ooclass']['classname'] = ''; preg_match_all("/(.*?)<\/type>(.*?)<\/varname><\/fieldsynopsis>/s", $match[1][$i], $match2); $en_classsynopsis[$i]['fieldsynopsis']['varname'] = $match2[2]; $en_classsynopsis[$i]['fieldsynopsis']['type'] = $match2[1]; } $lang_classsynopsis = array(); preg_match_all("/(\s.*?)<\/classsynopsis>/s", $lang_content, $match); for( $i = 0; $i < count($match[1]); $i++) { preg_match_all("/(.*?)<\/classname><\/ooclass>/s", $match[1][$i], $match2); ( isset($match2[1][0]) ) ? $lang_classsynopsis[$i]['ooclass']['classname'] = $match2[1][0] : $lang_classsynopsis[$i]['ooclass']['classname'] = ''; preg_match_all("/(.*?)<\/type>(.*?)<\/varname><\/fieldsynopsis>/s", $match[1][$i], $match2); $lang_classsynopsis[$i]['fieldsynopsis']['varname'] = $match2[2]; $lang_classsynopsis[$i]['fieldsynopsis']['type'] = $match2[1]; } // Verify for( $i=0; $i < count($en_classsynopsis); $i++) { if( !isset($lang_classsynopsis[$i]['ooclass']['classname']) ) { $lang_classsynopsis[$i]['ooclass']['classname'] = ''; } // fieldsynopsis if( $en_classsynopsis[$i]['ooclass']['classname'] != $lang_classsynopsis[$i]['ooclass']['classname'] ) { $nb_error['classsynopsis'] ++; $result_error[] = array( "libel" => "Error in ooclass, classname :", "value_en" => $en_classsynopsis[$i]['ooclass']['classname'], "value_lang" => $lang_classsynopsis[$i]['ooclass']['classname'] ); } // methodparam for( $j = 0; $j < count($en_classsynopsis[$i]['fieldsynopsis']['varname']); $j++ ) { if( !isset($lang_classsynopsis[$i]['fieldsynopsis']['varname'][$j]) ) { $lang_classsynopsis[$i]['fieldsynopsis']['varname'][$j] = ''; } // fieldsynopsis name if( $en_classsynopsis[$i]['fieldsynopsis']['varname'][$j] != $lang_classsynopsis[$i]['fieldsynopsis']['varname'][$j] ) { $nb_error['classsynopsis'] ++; $result_error[] = array( "libel" => "Error in fieldsynopsis, varname :", "value_en" => $en_classsynopsis[$i]['fieldsynopsis']['varname'][$j], "value_lang" => $lang_classsynopsis[$i]['fieldsynopsis']['varname'][$j], "type" => "methodparam_fieldsynopsis_name", ); } if( !isset($lang_classsynopsis[$i]['fieldsynopsis']['type'][$j]) ) { $lang_classsynopsis[$i]['fieldsynopsis']['type'][$j] = ''; } // fieldsynopsis type if( $en_classsynopsis[$i]['fieldsynopsis']['type'][$j] != $lang_classsynopsis[$i]['fieldsynopsis']['type'][$j] ) { $nb_error['classsynopsis'] ++; $result_error[] = array( "libel" => "Error in fieldsynopsis, type :", "value_en" => $en_classsynopsis[$i]['fieldsynopsis']['type'][$j], "value_lang" => $lang_classsynopsis[$i]['fieldsynopsis']['type'][$j], "type" => "methodparam_fieldsynopsis_type", ); } } } // END : classsynopsis // table $en_table = array(); preg_match_all("//s", $en_content, $match2); $en_table = $match2[1]; $lang_table = array(); preg_match_all("//s", $lang_content, $match2); $lang_table = $match2[1]; for( $i=0; $i < count($en_table); $i++) { preg_match_all("/(.*?)<\/row>/s", $en_table[$i], $match3); preg_match_all("/(.*?)<\/row>/s", $lang_table[$i], $match4); $nb_en = count($match3[1]); $nb_lang = count($match4[1]); if( $nb_en != $nb_lang ) { $nb_error['table'] ++; $result_error[] = array( "libel" => "Error in table listing : $nb_en row(s) in EN, and $nb_lang in $LANG.", "value_en" => "N/A", "value_lang" => "N/A", "type" => "table", ); } } // END : table // para $en_para = 0; preg_match_all("//s", $en_content, $match2); $en_para = count($match2[0]); $lang_para = 0; preg_match_all("//s", $lang_content, $match2); $lang_para = count($match2[0]); if( $en_para != $lang_para ) { $nb_error['para'] ++; $result_error[] = array( "libel" => "Error in para tag : $en_para tag in EN, and $lang_para in $LANG.", "value_en" => "N/A", "value_lang" => "N/A", "type" => "para", ); } // END : para // literal $en_literal = 0; preg_match_all("//s", $en_content, $match2); $en_literal = count($match2[0]); $lang_literal = 0; preg_match_all("//s", $lang_content, $match2); $lang_literal = count($match2[0]); if( $en_literal != $lang_literal ) { $nb_error['literal'] ++; $result_error[] = array( "libel" => "Error in literal tag : $en_literal tag in EN, and $lang_literal in $LANG.", "value_en" => "N/A", "value_lang" => "N/A", "type" => "literal", ); } // END : literal return $result_error; } // do_check function check($lang_file, $en_file) { global $final_result; if( !is_file($en_file) ) { return false; } $en_content = file_get_contents($en_file); $lang_content = file_get_contents($lang_file); $result = do_check($en_content, $lang_content); if( count($result) > 0 ) { $final_result[] = array( "file" => $lang_file, "error" => $result ); } } // check // Grabs the revision tag and stores credits from the file given function get_tags($file, $val = "en-rev") { // Read the first 500 chars. The comment should be at // the beginning of the file if( !is_file($file) ) { return false; } $fp = @fopen($file, "r") or die ("Unable to read $file."); $line = fread($fp, 500); fclose($fp); // No match before the preg $match = array(); // Check for English CVS revision tag (. is for $ in the preg!), // Return if this was needed (it should be there) if ($val == "en-rev") { preg_match("//", $line, $match); return isset($match[1]) ? $match[1] : false; } else { // Check for the translations "revision tag" preg_match("/

PHP Manual : Tools for translator

Generated: '.date("r").'   /   Language: '.$LANG.'

Info : Only files who are sync with EN version are checked.

'; $nb_file = count($final_result); $html.='
Error Libel Nb error
Chapter
Check "chapter" tag & attribut consistency.
'.(($nb_error['chapter'] == 0)?'-':''.$nb_error['chapter'].'').'
Appendix
Check "Appendix" tag & attribut consistency.
'.(($nb_error['appendix'] == 0)?'-':''.$nb_error['appendix'].'').'
qandaentry
Check "qandaentry" tag & attribut consistency.
'.(($nb_error['qandaentry'] == 0)?'-':''.$nb_error['qandaentry'].'').'
link
Check "link" tag & attribut consistency.
Error can be just a different order of link in the page.
'.(($nb_error['link'] == 0)?'-':''.$nb_error['link'].'').'
sect1
Check "sect1" tag & attribut consistency.
'.(($nb_error['sect1'] == 0)?'-':''.$nb_error['sect1'].'').'
book
Check "book" tag & attribut consistency.
'.(($nb_error['book'] == 0)?'-':''.$nb_error['book'].'').'
preface
Check "preface" tag & attribut consistency.
'.(($nb_error['preface'] == 0)?'-':''.$nb_error['preface']).'
section
Check "section" tag & attribut consistency.
'.(($nb_error['section'] == 0)?'-':''.$nb_error['section'].'').'
varlistentry
Check "varlistentry" tag & attribut consistency.
'.(($nb_error['varlistentry'] == 0)?'-':''.$nb_error['varlistentry'].'').'
reference
Check "reference" tag & attribut consistency.
'.(($nb_error['reference'] == 0)?'-':''.$nb_error['reference'].'').'
refentry
Check "refentry" tag & attribut consistency.
'.(($nb_error['refentry'] == 0)?'-':''.$nb_error['refentry'].'').'
refsect1
Check "refsect1" tag & attribut consistency.
'.(($nb_error['refsect1'] == 0)?'-':''.$nb_error['refsect1'].'').'
methodsynopsis
Check "methodsynopsis" tag & attribut consistency.
'.(($nb_error['methodsynopsis'] == 0)?'-':''.$nb_error['methodsynopsis'].'').'
refpurpose
Check "refpurpose" tag & warn if there is a point at the end.
'.(($nb_error['refpurpose'] == 0)?'-':''.$nb_error['refpurpose'].'').'
seealsoMember
Check "SeeAlso" section & warn if there is less member in translation than in EN version.
'.(($nb_error['seealsoMember'] == 0)?'-':''.$nb_error['seealsoMember'].'').'
cdata
Check "cdata" section & warn if there is less cdata section in translation than in EN version.
'.(($nb_error['cdata'] == 0)?'-':''.$nb_error['cdata'].'').'
classsynopsis
Check "classsynopsis" tag & attribut consistency.
'.(($nb_error['classsynopsis'] == 0)?'-':''.$nb_error['classsynopsis'].'').'
row in Table
Check number of rows in table tag.
'.(($nb_error['table'] == 0)?'-':''.$nb_error['table'].'').'
para
Check number of para tag.
'.(($nb_error['para'] == 0)?'-':''.$nb_error['para'].'').'
literal
Check number of literal tag.
'.(($nb_error['literal'] == 0)?'-':''.$nb_error['literal'].'').'
Total :
In '.$nb_file.' file(s)
'.$nb_error_all.'
'; for( $i = 0; $i < $nb_file; $i++ ) { $html.= ' '; for( $j=0; $j < count($final_result[$i]['error']); $j++) { $html.= ' '; } $html.= '
'.$final_result[$i]['file'].'
'.$final_result[$i]['error'][$j]['libel'].'
Value in EN : '.$final_result[$i]['error'][$j]['value_en'].'
Value in '.strtoupper($LANG).' : '.$final_result[$i]['error'][$j]['value_lang'].'
Type : '.$final_result[$i]['error'][$j]['type'].'
'; } $html.= ''; echo $html; ?>