{"id":3263,"date":"2017-12-01T08:18:07","date_gmt":"2017-12-01T07:18:07","guid":{"rendered":"https:\/\/www.opengis.ch\/?p=3263"},"modified":"2020-04-29T16:05:13","modified_gmt":"2020-04-29T14:05:13","slug":"interlis-translation","status":"publish","type":"post","link":"https:\/\/www.opengis.ch\/de\/2017\/12\/01\/interlis-translation\/","title":{"rendered":"Interlis translation"},"content":{"rendered":"<p>Lately, I have been confronted with the need of translating Interlis files (from French to German) to use queries originally developed for German data. I decided to create an automated convertor for Interlis (version 1) Transfer Format files (.ITF) based on the existing cadastral data model from the Swiss confederation (DM01AVCH).<br \/>\nThe ILI model file conversion has been achieved manually once. This was quite simple since the used model is an extension with little to no difference with respect to the confederation model which already exists in several languages.<br \/>\nNext was to automate the conversion of the ITF files.<br \/>\nA program developed by Swisstopo called DM01AVCH_Translator existed to translate confederation model\u2019s ITF files. Originally developed in 2008, the solution is sadly no longer maintained by Swisstopo and was available on Windows only. Moreover it can\u2019t be completely automated since some interaction is required in the GUI and some tweaks in the output file are needed.<br \/>\nSo I decided to develop a dedicated and fully automated solution which I\u2019d like to share since it is easily adaptable to new scenarios and hopefully can avoid troubles to those who are playing with Interlis files!<br \/>\nYou can find this utility, written in Python, called ITF_Translator on <a href=\"https:\/\/github.com\/opengisch\/ITF_Translator\">https:\/\/github.com\/opengisch\/ITF_Translator<\/a><\/p>\n<h1>ITF_Translator<\/h1>\n<p>ITF_Translator is capable of translating Interlis v1 transfer files (ITF) to another language thanks to a dictionary text file. Currently restricted to German, French and Italian, it is a simple operation to add support for other languages.<br \/>\n<span class=\"lang:default decode:true  crayon-inline \">ITFTranslator<\/span> class from <span class=\"lang:default decode:true  crayon-inline \">itf_translator_generic<\/span> module creates a translator object based on a custom dictionary file whereas some custom translations rules can be added.<br \/>\nTwo extensions of <span class=\"lang:default decode:true  crayon-inline \">ITFTranslator<\/span> exist already and contain everything needed to translate <span class=\"lang:default decode:true  crayon-inline \">DM01AVCH<\/span>\u00a0 (cadastral data model from the Swiss confederation) and <span class=\"lang:default decode:true  crayon-inline \">MD01MOVD<\/span>\u00a0 (cadastral data model from Canton Vaud). These classes are <span class=\"lang:default decode:true  crayon-inline \">ITFTranslatorDM01AVCH<\/span> respectively <span class=\"lang:default decode:true  crayon-inline\">ITFTranslatorMD01MOVD<\/span>.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/documents.lucidchart.com\/documents\/d4616523-4323-46c8-b964-a2d408f2051c\/pages\/0_0?a=204&amp;x=162&amp;y=206&amp;w=1276&amp;h=308&amp;store=1&amp;accept=image%2F*&amp;auth=LCA%2090d759de416ce1d7dc7b7a42bd7f9aa5951828d9-ts%3D1505628781\" width=\"957\" height=\"231\" \/><\/p>\n<h2>Dictionary file<\/h2>\n<p>The dictionary file is a text file composed of line formatted as follows:<br \/>\n<span class=\"lang:default decode:true crayon-inline\">german_translation;french_tranlsation;italian_translation<\/span><br \/>\nwith the following rules:<\/p>\n<ul>\n<li>line beginning with &#8218;#&#8216; and blank lines are ignored<\/li>\n<li>no spaces are allowed, use underscores &#8218;_&#8216; instead<\/li>\n<\/ul>\n<p>Lines are read from the top to the bottom. If a translation key is repeated, the last one will be used.<br \/>\nThe existing dictionaries for <span class=\"lang:default decode:true  crayon-inline \">ITFTranslatorDM01AVCH<\/span> and <span class=\"lang:default decode:true  crayon-inline\">ITFTranslatorMD01MOVD<\/span> are based on the dictionary from Swisstopo\u2019s tool.<\/p>\n<h2>Usage example<\/h2>\n<p>To translate the file <span class=\"lang:default decode:true  crayon-inline \">input.itf<\/span>\u00a0 based on the <span class=\"lang:default decode:true  crayon-inline \">DM01AVCH<\/span>\u00a0 model from French to German:<\/p>\n<pre class=\"lang:python decode:true\">translator = ITFTranslatorDM01AVCH('\/home\/mario\/input.itf')\ntranslator.translate('output.itf', ITFTranslator.LANGUAGE_FR, ITFTranslator.LANGUAGE_DE)<\/pre>\n<p>A file named <span class=\"lang:default decode:true  crayon-inline \">output.itf<\/span> is created and contains the translation.<\/p>\n<h2>Rules<\/h2>\n<p>The <span class=\"lang:default decode:true  crayon-inline \">ITFTranslatorDM01AVCH<\/span> and <span class=\"lang:default decode:true  crayon-inline \">ITFTranslatorMD01MOVD<\/span> extend <span class=\"lang:default decode:true  crayon-inline \">ITFTranslator<\/span> class and implement required additional rules to correctly translate the respective ITF files. These rules exist to handle non reversible translations. For instance in the <span class=\"lang:default decode:true  crayon-inline \">DM01AVCH<\/span> model, \u201celement_lineaire\u201d in French can be translated in German to either \u201clinienelement\u201d or \u201clinienobjekt\u201d depending on the topic. Hereby, we have the opportunity to easily add some context dependant rules which could handle any specific use-case.<br \/>\nLooking at the code <span class=\"lang:default decode:true  crayon-inline \">ITFTranslatorDM01AVCH<\/span> demonstrates how easy it is to create translators for other models. Rules are objects of the class <span class=\"lang:default decode:true  crayon-inline \">SpecialCaseRule<\/span><\/p>\n<pre class=\"lang:python decode:true\" title=\"Class SpecialCaseRule\">class SpecialCaseRule:\n    \"\"\"Handle non reversible translations\"\"\"\n    def __init__(self, language_from, language_to, topic, table, translation):\n        \"\"\"Constructor\n        :param int language_from:\n            the initial language. See the already defined class variables\n        :param int language_to:\n            the final language. See the already defined class variables\n        :param str topic:\n            the name of the topic\n        :param str table:\n            the name of the table\n        :param str translation:\n            the translation to use\n        \"\"\"\n        self.language_from = language_from\n        self.language_to = language_to\n        self.topic = topic\n        self.table = table\n        self.translation = translation\n<\/pre>\n<p>The goal of these rules is to define the translation of a table within a precise topic. Dictionary based only translations indistinctively treat every occurrence of the words in the source file. The proposed approach is convenient because it combines simple dictionary files which are valid in most cases, and rules to handle specific scenarios.<br \/>\nAn example of a rule defined for <span class=\"lang:default decode:true  crayon-inline\">ITFTranslatorDM01AVCH<\/span> is:<\/p>\n<pre class=\"lang:python decode:true \">SpecialCaseRule(\n    ITFTranslator.LANGUAGE_FR, ITFTranslator.LANGUAGE_DE,\n    'Bords_de_plan', 'Element_lineaire', 'Linienobjekt')<\/pre>\n<p>It solves the example cited previously, specifying that the translation from French to German of the table \u201cElement_lineaire\u201d in the topic \u201cBords_de_plan\u201d is \u201cLinienobjekt\u201d while the dictionary file says the translation of \u201cElement_lineaire\u201d is \u201cLinienelemen\u201d for any other case.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lately, I have been confronted with the need of translating Interlis files (from French to German) to use queries originally developed for German data. I decided to create an automated convertor for Interlis (version 1) Transfer Format files (.ITF) based on the existing cadastral data model from the Swiss confederation [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7,14],"tags":[125],"class_list":["post-3263","post","type-post","status-publish","format-standard","hentry","category-interlis","category-python","tag-qgis-org"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":14123,"url":"https:\/\/www.opengis.ch\/de\/2024\/02\/07\/qgis-model-baker-und-interlis-kurse-2023\/","url_meta":{"origin":3263,"position":0},"title":"QGIS Model Baker und INTERLIS Kurs 2024","author":"Dave Signer","date":"7. Februar 2024","format":false,"excerpt":"Der Tageskurs f\u00fcr QGIS Model Baker und das vorg\u00e4ngige INTERLIS Crash-Webinar erfreuten sich letztes Jahr grosse Beliebtheit. Deshalb m\u00f6chten wir es dir auch dieses Jahr erm\u00f6glichen INTERLIS-Modelbackmeister:in zu werden\ud83e\uddc1 Das INTERLIS Webinar beinhaltet die Grundkenntnisse, die f\u00fcr den QGIS Model Baker Kurs vorausgesetzt werden. Allerdings k\u00f6nnen die beiden Kurse unabh\u00e4ngig\u2026","rel":"","context":"In &quot;Unkategorisiert&quot;","block_context":{"text":"Unkategorisiert","link":"https:\/\/www.opengis.ch\/de\/category\/unkategorisiert\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":12398,"url":"https:\/\/www.opengis.ch\/de\/2021\/12\/07\/model-baker-6-7-noch-nie-wars-so-einfach\/","url_meta":{"origin":3263,"position":1},"title":"Model Baker 6.7 &#8211; Noch nie war&#8217;s so einfach","author":"Dave Signer","date":"7. Dezember 2021","format":false,"excerpt":"Den QGIS Model Baker gibt's ja schon lange. Vor mehr als vier Jahren kam die Version 1.0.0 heraus - damals noch unter dem Namen QGIS Project Generator. Seither ist viel geschehen. Und speziell in diesem Jahr ist viel betreffend Benutzbarkeit gegangen. Der UsabILIty Hub ist integriert, Baskets und Datasets werden\u2026","rel":"","context":"In &quot;GIS&quot;","block_context":{"text":"GIS","link":"https:\/\/www.opengis.ch\/de\/category\/gis\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2021\/11\/modelbaker_schema_configuration.png?fit=842%2C767&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2021\/11\/modelbaker_schema_configuration.png?fit=842%2C767&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2021\/11\/modelbaker_schema_configuration.png?fit=842%2C767&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2021\/11\/modelbaker_schema_configuration.png?fit=842%2C767&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":14170,"url":"https:\/\/www.opengis.ch\/2023\/03\/06\/interlis-crashcourse-webinar\/","url_meta":{"origin":3263,"position":2},"title":"INTERLIS Crash Course Webinar","author":"Marco Bernasocchi","date":"6. M\u00e4rz 2023","format":false,"excerpt":"The goal of this crash course is to introduce \u201ccomplete beginners\u201d to INTERLIS. After the crash course, participants will know what INTERLIS is, how it is used, how to read a model, and how to find their way around it. They will also be able to model a simple example\u2026","rel":"","context":"In &quot;INTERLIS &amp; Model Baker courses&quot;","block_context":{"text":"INTERLIS &amp; Model Baker courses","link":"https:\/\/www.opengis.ch\/de\/category\/courses\/interlis-model-baker-courses\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":12445,"url":"https:\/\/www.opengis.ch\/fr\/2021\/12\/08\/model-baker-6-7-cela-na-jamais-ete-aussi-simple\/","url_meta":{"origin":3263,"position":3},"title":"Model Baker 6.7 &#8211; Cela n&#8217;a jamais \u00e9t\u00e9 aussi simple","author":"Dave Signer","date":"8. Dezember 2021","format":false,"excerpt":"Le plugin QGIS Model Baker existe depuis longtemps. La version 1.0.0 est sortie il y a plus de quatre ans, \u00e0 l'\u00e9poque sous le nom de QGIS Project Generator. Depuis, il s'est pass\u00e9 beaucoup de choses. Et cette ann\u00e9e en particulier, beaucoup de choses ont chang\u00e9 en ce qui concerne\u2026","rel":"","context":"In &quot;GIS&quot;","block_context":{"text":"GIS","link":"https:\/\/www.opengis.ch\/fr\/category\/gis-fr\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2021\/11\/modelbaker_schema_configuration.png?fit=842%2C767&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2021\/11\/modelbaker_schema_configuration.png?fit=842%2C767&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2021\/11\/modelbaker_schema_configuration.png?fit=842%2C767&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2021\/11\/modelbaker_schema_configuration.png?fit=842%2C767&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":15036,"url":"https:\/\/www.opengis.ch\/fr\/2023\/03\/06\/interlis-crashcourse-webinar\/","url_meta":{"origin":3263,"position":4},"title":"INTERLIS Crashcourse Webinar","author":"Marco Bernasocchi","date":"6. M\u00e4rz 2023","format":false,"excerpt":"L'objectif de ce cours acc\u00e9l\u00e9r\u00e9 est de familiariser les \"novices\" avec INTERLIS. Apr\u00e8s le cours intensif, ils sauront ce qu'est INTERLIS, comment l'utiliser et comment lire un mod\u00e8le et s'y retrouver. En outre, ils seront capables de mod\u00e9liser eux-m\u00eames un exemple simple de mod\u00e8le.","rel":"","context":"In &quot;Cours INTERLIS &amp; Model Baker&quot;","block_context":{"text":"Cours INTERLIS &amp; Model Baker","link":"https:\/\/www.opengis.ch\/fr\/category\/cours\/cours-interlis-model-baker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":15024,"url":"https:\/\/www.opengis.ch\/de\/2023\/03\/06\/interlis-crashkurs-webinar\/","url_meta":{"origin":3263,"position":5},"title":"INTERLIS Crashkurs Webinar","author":"Marco Bernasocchi","date":"6. M\u00e4rz 2023","format":false,"excerpt":"Ziel dieses Crashkurses ist es, \u201cblutigen Anf\u00e4nger:innen\u201d INTERLIS n\u00e4her zu bringen. Nach dem Crashkurs werden sie wissen, was INTERLIS ist, wie es angewendet wird und wie ein Modell gelesen wird und man sich darin zurechtfindet. Weiter werden sie f\u00e4hig sein, ein einfaches Beispielmodell selbst zu modellieren.","rel":"","context":"In &quot;INTERLIS &amp; Model Baker Kurse&quot;","block_context":{"text":"INTERLIS &amp; Model Baker Kurse","link":"https:\/\/www.opengis.ch\/de\/category\/kurse\/interlis-model-baker-kurse\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.opengis.ch\/wp-content\/uploads\/2022\/11\/modelbaker_course.png?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"jetpack_shortlink":"https:\/\/wp.me\/pbdBtI-QD","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/posts\/3263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/comments?post=3263"}],"version-history":[{"count":1,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/posts\/3263\/revisions"}],"predecessor-version":[{"id":4679,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/posts\/3263\/revisions\/4679"}],"wp:attachment":[{"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/media?parent=3263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/categories?post=3263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opengis.ch\/de\/wp-json\/wp\/v2\/tags?post=3263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}