Package: mobile-strings-converter
Mobile strings converterA Python package that converts Android & iOS strings files to any supported file type.Report Bug·Request Feature·Ask QuestionTable of ContentsAbout the ProjectProject StructureBuilt WithRelease FilesUsageTo Execute the ScriptTo Import the Package Into Your ProjectTo Open the CodeNotesList of Indic Languages Supported by PDF filesList of Languages Not Supported by PDF filesRoadmapContributingLicenseAuthorsAcknowledgmentsSupportAbout the ProjectI tried to do the whole process of converting a strings resource file into a spreadsheet in Google Sheets by hand and, even though you can do it with the optionData > Split text to columns,
it involves wasting your time generating the spreadsheet manually. Due to that, I decided to build a time-efficient solution, which consists on running a Python script in order to achieve that with any file type.Moreover, not only this script can be executed on its own, it also can be installed as a package viaPyPI(more informationhereabout how to install it).The file types supported by the package are the following:Android strings format (*.xml)CSVGoogle Sheets supportHTMLiOS strings format (*.strings)JSONMDODSPDFXLSXYAMLProject StructureRoot directories:.github/workflows: GitHub workflows. It also includes the templates for issues and pull requests, as well as thedepandabot.ymlfile for Dependabot configuration.docs: Contains files related to the documentation of the project.src/mobile_strings_converter:  Contains the source code files.tests: Contains unit tests to ensure the correct functionality of the package. It also includes thefilesdirectory, which contains a few demo files in different formats to use in the unit tests.Root files:.gitignore: File used by the version control system Git to specify files or directories that should be ignored by Git when tracking changes to a project..pre-commit-config.yaml: Configuration file used bypre-commit, a tool that runs checks (such as linting, testing, or formatting) on the code before you commit changes to version control. The file specifies which checks pre-commit should run and how it should run them.LICENSE: Project license, which isMIT.poetry.lock: File generated byPoetry, a package manager for Python, that contains the exact versions of all packages used by a project. The file is used to ensure that all members of a development team are using the same versions of packages, even if different versions are available in the package repository.pyproject.toml: Configuration file used byPoetry. It specifies the metadata for a Python project, including the project name, version, description, author, license and dependencies.README.md: What you are reading right now.requirements.txt: Lists the names and versions of each package used to build this project. To install the requirements, executepip install -r requirements.txt.requirements-dev.txt: Lists the names and versions of each package used in the development stage of this project. To install the requirements, executepip install -r requirements-dev.txt.Built Withopenpyxl: To generate ODS and XLSX files.gspread: To generate spreadsheets in Google Sheets.protobuf: Used bygoogle.oauth2.credentialsto authenticate to the user's Google account in order to create the spreadsheet in Google Sheets.PyYAML: To generate YAML files.arabic-reshaperandpython-bidi: To add arabic characters support for PDF files.fpdf2: To generate PDF files.lingua-language-detector: To recognize thevaluelanguage when writing a PDF in order to know what font to use.(back to top)Release FilesFileDescriptionSizemobile-strings-converter.zipStandard language support for PDF files (over 100 languages, including RTL)0.32 MBmobile-strings-converter-indic.zipPDF file support for Indic languages (see list)1.40 MBmobile-strings-converter-zh-ja.zipPDF file support for Japanese and Chinese (simplified and traditional)7.17 MBmobile-strings-converter-ko.zipPDF file support for Korean0.46 MBmobile-strings-converter-th.zipPDF file support for Thai0.37 MBmobile-strings-converter-all.zipPDF file support for almost all languages (see exceptions)8.43 MB(back to top)UsageTo Execute The ScriptDownload thereleasethat is best suited to your needs.Open the command line and runpip install -r path/to/requirements.txtto install the required packages to execute the script.Example of a basic command to convert a.xmlor.stringsfile to another file type:path/to/python path/to/mobile_strings_converter.py path/to/<*.xml | *.strings> -o path/to/*.<SUPPORTED FILE TYPE EXTENSION>To Generate a Spreadsheet in Google SheetsBefore going further into running the commands to do so, please note that you will have to generate aservice_account.jsonfile. You can do the following to get one:Go to theGoogle Cloud Console.Create a new project or select an existing project.Go to theAPIs & Servicespage, click onDashboardand then click onEnable APIs and Services.Search forGoogle Sheets APIand enable it.Go to theCredentialspage, click onCreate credentials, and then chooseService account.Give your service account a name and select a role. For this purpose, you can selectProject -> Editor.Click on theCreate keybutton, select the JSON format and download theservice_account.jsonfile.Share your Google Sheets file with the email address that is specified in theclient_emailfield in theservice_account.jsonfile.Alternatively, you can create an XLSX file and open it in Google Sheets if you do not want to go through the hassle of generating theservice_account.jsonfile.Once you have generated theservice_account.jsonfile, you can generate a spreadsheet in Google Sheets by running the following command:path/to/python path/to/mobile_strings_converter.py path/to/<strings.xml | Localizable.strings> -gs <SHEET NAME> -c path/to/service_account.jsonIf you want to generate an output file along with the spreadsheet, run this:path/to/python path/to/mobile_strings_converter.py path/to/<strings.xml | Localizable.strings> -gs <SHEET NAME> -c path/to/service_account.json -o path/to/strings.<SUPPORTED FILE TYPE EXTENSION>Script flags-h,--help: Show help-o,--output-filepath: Output filepath where you want to store the converted file. Its extension can be any of the file types listedhere.-g,--google-sheets: Creates a spreadsheet in Google Sheets with the name passed as argument.-c,--credentials<service_account.jsonfilepath>: Mandatory if you want to generate a spreadsheet in your Google account.-p,--print-comments: If present, indicates that commented strings will be printed in the output file.To Import the Package Into Your ProjectRunpip install mobile-strings-converterImport the package and the wrapper function with this line of code:from mobile_strings_converter import convert_strings.To Open the CodeClone the project with thegit clone https://github.com/HenestrosaConH/mobile-strings-converter.gitcommand.Open it in your favourite IDE (mine isPyCharm)(back to top)NotesList of Indic Languages Supported by PDF filesHindiMarathuOriyaTibetanGujaratiTeluguTamilPunjabiList of Languages Not Supported by PDF filesBengali(not possible to print correctly usingfpdf2)Dhivehi(not recognized bylingua-language-detector)Kannada(not recognized bylingua-language-detector)Khmer(not recognized bylingua-language-detector)Lao(not recognized bylingua-language-detector)Malayalam(not recognized bylingua-language-detector)Meiteilon (manipuri)(not recognized bylingua-language-detector)Myanmar burmese(not possible to print correctly usingfpdf2)Odia (Oriya)(not recognized bylingua-language-detector)Sinhala(not recognized bylingua-language-detector)Tigrinya(not recognized bylingua-language-detector)(back to top)RoadmapAdd support for multiple.xml/.stringsfiles input.Add support for converting a file (not.xmlnor.strings) to a strings resource file.Make a web version.You can propose a new feature creating anissue.(back to top)ContributingContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make aregreatly appreciated.
Please, read theCONTRIBUTING.mdfile, where you can find more detailed information about how to contribute to the project.(back to top)LicenseDistributed under the MIT License. SeeLICENSEfor more information.(back to top)AuthorsHenestrosaConHhenestrosaconh@gmail.com(José Carlos López Henestrosa)See also the list ofcontributorswho participated in this project.(back to top)AcknowledgmentsI have made use of the following resources to make this project:Best-README-TemplateImg ShieldsHow to create a Python packageIcon created by Midjourney(back to top)Support(back to top)