Metadata-Version: 2.1
Name: python-tmx
Version: 0.1.3
Summary: A Python library for creating, editing and exporting tmx files
Author-email: Enzo Agosta <agosta.enzowork@gmail.com>
Maintainer-email: Enzo Agosta <agosta.enzowork@gmail.com>
License: MIT License
        
        Copyright (c) 2023 Enzo Agosta
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/ChonkyYoshi/python-tmx
Project-URL: Repository, https://github.com/ChonkyYoshi/python-tmx
Keywords: tmx,localization
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lxml

# Python-tmx
A python library based on lxml to help create, edit, and export tmx files quickly.

# Installation
Install the latest version of the library using Pypi, note that lxml is required.
```python
pip install -U python-tmx
```
# How to use
## Basics
A tmx file is represented as a `tmx` object, containing a `header` and a list of `tu` object. Each tu is then further divided into `tuv` objects, each having a list of `run` object representing text and the different tags available.
Further, `header`, `tu` and `tuv` objects all have a list of `note` and `prop` objects.

Every possible attribute defined by the spec is represented by an attibute of that object accesible using dot notation. so for example, if you want to change the 'creationtool' attribute of a tmx header you can simply do the following:
```python
tmx_file.header.creationtool = "python-tmx"
```
## Simple Usage
The below snippet shocases how to make a multilingual tmx bilingual with very little effort
```python
from tmx.structural import tmx
from tmx import load_tmx

tmx_file: tmx = load_tmx("tmx-file.tmx")  # Load a tmx file into memory
for tu in tmx_file.tus:  # loop through all tus
    for index, tuv in enumerate(tu.tuvs):  # loop through all tuv
        if tuv.xmllang not in ["en-US", "fr-FR"]:  # check tuv language
            tu.tuvs.pop(index)  # remove tuv if not english or french
tmx_file.export("new-tmx.tmx")  # export now bilingual tmx object into a tmx file
```
