Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
675c469
add auth type TableauIDWithMFA
jacalata Jun 14, 2024
c8a8135
Update contributing.md
jacalata Jun 14, 2024
0ac7ac1
Update company name to Salesforce
bcantoni Jun 19, 2024
fa35f73
Merge pull request #299 from tableau/bcantoni/update-company-name-2
jacalata Jun 19, 2024
d24b91f
copy updated loc files
jacalata Jul 17, 2024
4e71aae
Updated dodo loc automation, updated binary loc files
jacalata Jul 17, 2024
4ea1fda
Automate finding missing strings
jacalata Jul 17, 2024
a0ab0b4
Tweak po file generation
jacalata Jul 17, 2024
fed9a37
change the 'Launching {command} line' to not need translation
jacalata Jul 18, 2024
1ef074f
Add a properties file to hold the strings not in the two monolith files
jacalata Jul 18, 2024
3ac3bdb
oops we needed that double encoding
jacalata Jul 19, 2024
1b3d538
add a bunch of scripts for strings
jacalata Jul 19, 2024
03b609b
small code changes for better logs/errors I ran into
jacalata Jul 19, 2024
c716b27
updated properties files, .mo files
jacalata Jul 19, 2024
fea6ea3
delete all intermediate po files
jacalata Jul 19, 2024
16d7948
revert visual launch change to reduce files in CL
jacalata Jul 19, 2024
cf0ac88
black, mypy
jacalata Jul 19, 2024
fac7f30
PR feedback
jacalata Jul 22, 2024
8856952
tyPo
jacalata Jul 22, 2024
592321b
Merge pull request #296 from tableau/jac/tabid-with-mfa
jacalata Jul 22, 2024
d2c4037
Update contributing.md
jacalata Jul 22, 2024
73425a2
explain quote replacements
jacalata Jul 23, 2024
c90ddfa
format
jacalata Jul 23, 2024
a2f9d6f
Update dodo.py
jacalata Jul 23, 2024
5853c8f
Update dodo.py
jacalata Jul 23, 2024
ce1183e
Update dodo.py
jacalata Jul 23, 2024
c53ff99
Update contributing.md
jacalata Jul 23, 2024
f3337f2
Merge pull request #302 from tableau/jac/string-localization
jacalata Jul 24, 2024
143a83a
fix glob reference to find strings in code
jacalata Aug 17, 2024
e1f80d3
Merge pull request #305 from tableau/jac/collect-missed-strings
jacalata Aug 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ pytest.xml
# doit
.doit.*

# localization intermediate files
*.po

# venv
site-packages

# local
tabcmd-dev
workon
test.junit.xml
*.out
9 changes: 5 additions & 4 deletions bin/i18n/msgfmt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#! /usr/bin/env python3
# Written by Martin v. Löwis <loewis@informatik.hu-berlin.de>

""" Updated to handle utf-8 files and give better error messages
"""
Fetched from https://github.com/python/cpython/blob/main/Tools/i18n/msgfmt.py
Updated to handle utf-8 files and give better error messages
TODO contribute back?
"""

Expand Down Expand Up @@ -107,7 +108,7 @@ def make(filename, outfile):
CTXT = 3

encoding = 'utf-8'
print("Assumed encoding", encoding)
print("msgfmt::Assumed encoding", encoding)

# Compute .mo name from .po name and arguments
if filename.endswith('.po'):
Expand Down Expand Up @@ -195,7 +196,7 @@ def make(filename, outfile):
try:
l = ast.literal_eval(l)
except:
print("ERROR (skipped)", lno, msgid)
print("\tERROR (skipped)", lno, msgid)
pass
if section == CTXT:
msgctxt += l.encode(encoding)
Expand Down
29 changes: 18 additions & 11 deletions bin/i18n/prop2po.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,51 @@
"""

import click

from datetime import datetime

@click.command()
@click.argument('source', type=click.File('rt', encoding='utf-8'))
@click.argument('destination', type=click.File('wt', encoding='utf-8'))
@click.option('-l', '--language', type=click.STRING, help='The translation language')
@click.option('-p', '--project', type=click.STRING, help='The name of the project')
@click.option('-e', '--encoding', type=click.STRING, help='The encoding wanted')
def to_po(source, destination, encoding, language, project):
@click.option('-c', '--copyright', type=click.STRING, help='The person/organization holding copyright')
def to_po(source, destination, encoding, language, project, copyright):
"""Converts a property file to a Gettext PO file.

SOURCE is the path of the property file to convert.

DESTINATION is the path of the Gettext PO file to create
"""

year = datetime.now().strftime('%Y')
header = """msgid ""
msgstr ""
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset={encoding}\\n"
"MIME-Version: 1.0\\n\\n"
"Content-Type: text/plain; charset={encoding}\\n\\n"
"Content-Transfer-Encoding: 8bit\\n"
"X-Generator: prop2po\\n"
"Project-Id-Version: {project}\\n"
"Language: {language}\\n"
# Copyright (C) YEAR Tableau Software
"""
# Copyright (C) {year} {copyright}
"""

lines = source.readlines()
print(lines)
destination.write(header.format(
language=language,
project=project,
encoding=encoding
encoding=encoding,
year=year,
copyright=copyright
))
for line in lines:
if not line.isspace():
parts = line.split('=')
# Split only on the first instance of '=' so that the character can also appear in the string
parts = line.split('=', 1)
# TODO it fails on comments/lines with less than two parts after splitting
destination.write('#:\n' + 'msgid "' + parts[0] + '"\n' 'msgstr "' + parts[1][:-1] + '"\n\n')
try:
destination.write('#:\n' + 'msgid "' + parts[0] + '"\n' 'msgstr "' + parts[1][:-1] + '"\n\n')
except IndexError as e:
print("FAILED on line{}".format(line))


if __name__ == '__main__':
Expand Down
19 changes: 14 additions & 5 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,15 @@ _(note that running mypy and black with no errors is required before code will b
> You can only build an executable for the platform you are running pyinstaller on. The spec for each platform is stored in tabcmd-*platform*.spec and the exact build commands for each platform can be checked in [our packaging script](.github/workflows//package.yml).

e.g for Windows
> pyinstaller tabcmd-windows.spec --clean --noconfirm --distpath ./dist/windows
> pyinstaller tabcmd-windows.spec --clean --distpath .\dist\windows

produces dist/tabcmd.exe
produces dist\windows\tabcmd.exe
To run the newly created executable, from a console window in the same directory as the file tabcmd.py:

> dist/tabcmd/tabcmd.exe --help
> dist\windows\tabcmd.exe --help
> dist\windows\tabcmd.exe publish --country FR --language FR cookie.twbx

To investigate what's packaged in the executable, use https://pyinstxtractor-web.netlify.app/



Expand All @@ -128,7 +131,9 @@ Strings are stored in /tabcmd/locales/[language]/*.properties by id and referred
> string = _("string.id")

For runtime execution these files must be converted from .properties -> .po -> .mo files. These .mo files will be bundled in the the package by pyinstaller. The entire conversion action is done by a .doit script:
> doit mo
> doit properties po mo
You can also check that there are no malformed/forgotten message keys in the code with
> doit strings

### Versioning

Expand All @@ -149,7 +154,11 @@ The version reflected in the executable (tabcmd -v) is stored in a metadata file
- run pyinstaller to create executables
- save the executable as an artifact on that job.

1. Find the artifacts created by this job and manually copy them to the new release. (Beware! of what the file type is, github does something weird with zipping it if you download with curl etc. TODO: automate workflow with a github action)
1. Find the artifacts created by this job and manually copy them to the new release.
- manually download. They will all be returned as zips
- unzip the windows.exe and mac[64].app.tar files and upload those
- do not unzip the linux app, github doesn't like it. upload as tabcmd.zip
(Pay attention to what the file type is, github also sends it as a zip if you download with curl etc. TODO: automate workflow with a github action)

1. To trigger publishing to pypi run the manual workflow on main with 'pypi'. (TODO: automate trigger)

Expand Down
Loading