<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Norbert Szolnoki on Medium]]></title>
        <description><![CDATA[Stories by Norbert Szolnoki on Medium]]></description>
        <link>https://medium.com/@norbertszolnoki?source=rss-4f5ac3e14705------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*phohDUl8FGa71TPp</url>
            <title>Stories by Norbert Szolnoki on Medium</title>
            <link>https://medium.com/@norbertszolnoki?source=rss-4f5ac3e14705------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 03:36:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@norbertszolnoki/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a localization workflow using GitHub]]></title>
            <link>https://medium.com/@norbertszolnoki/building-a-localization-workflow-for-github-a1d57ea52cc9?source=rss-4f5ac3e14705------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1d57ea52cc9</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Norbert Szolnoki]]></dc:creator>
            <pubDate>Tue, 28 Feb 2023 10:23:41 GMT</pubDate>
            <atom:updated>2023-03-14T08:19:15.313Z</atom:updated>
            <content:encoded><![CDATA[<p>Multilingual CSV files are commonly used by developers to store and transfer translation content to LSPs. Since so much of the development environment is automated or semi-automated, why not automate the CSV transfer process as well? In this tutorial, you’ll learn how to implement a CSV file import/export integration between Gridly and GitHub, using a AWS Lambda script executed straight from Gridly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9PJhwTht6gipZkDGeZJZQ.png" /></figure><h3>Workflow steps for a localization workflow using Github</h3><p>1 — Empty source strings stored in a CSV file on GitHub</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rdq6Kz5hOjEMphZDRC-2OQ.png" /></figure><p>2 — Importing empty strings into <a href="https://www.gridly.com/">Gridly</a> via a <a href="https://help.gridly.com/hc/en-us/sections/7497820076829-Automations">Gridly automation</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hnWMhurSlYnP0ldYQlZjfg.png" /></figure><p>3 — Localization is performed in Gridly or in a connected platform such as like <a href="https://www.gridly.com/integrations/memoq/">memoQ</a> or <a href="https://www.gridly.com/integrations/phrase/">Phrase</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HdgXm-Uib6yQDSLbdePsBg.png" /></figure><p>4 — Gridly automatically updates the source file on GitHub</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SuXc97eTZlQSyFL_UmZjbg.png" /></figure><p>5 — The commit of the source file update</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OHZT06ihUiZpz-lKAKupVA.png" /></figure><h3>Implementing the integration</h3><p>While this tutorial uses Python as an example, you can use any coding language with <a href="https://www.gridly.com/docs/api/#introduction">Gridly’s API</a>.</p><h3>Importing data from GitHub into Gridly</h3><ol><li>Find the files on GitHub</li></ol><p>To find the CSV files on GitHub, use the tree call of a branch to return all files in all subfolders. Filter the results by files ending with <em>.csv</em>.</p><p>2. Identify the file contents</p><p>Use the <em>download_url</em> value of the file to obtain its content.</p><p>3. Store the file path</p><p>Gridly uses a tree system called Paths to store files in a hierarchy. Create a new column in the file content from the last step and add the <em>Path</em> variable of the file to every row. When we push the updated file back to GitHub, we’ll know the exact location of each file.</p><p>4. Create columns in Gridly for file headers</p><p>To parse your CSV, create columns in Gridly that match your columns in the CSV. By default, Gridly creates multiple-line columns with the name and ID of your CSV column. Edit the Gridly columns as needed — for example, change the column type to Localization and select a language. This has no effect on the integration with GitHub and only serves to make content easier to find in Gridly.</p><p>5. Upload the file into your Grid</p><p>CSV file import is one of the many calls you can perform with Gridly’s rich API, which can handle any action also permitted within the Gridly UI.</p><h3>Code example: file import into Gridly</h3><pre>import base64<br>import io<br>import requests<br>import json<br>import csv<br>import re<br>from io import StringIO<br><br><br>def getFiles(github_api_key, github_owner, github_repo, github_branch):<br>    url = &quot;https://api.github.com/repos/&quot; + github_owner + &quot;/&quot; + github_repo + &quot;/git/trees/&quot; + github_branch + &quot;?recursive=1&quot;<br>    payload={}<br>    headers = {<br>    &#39;Authorization&#39;: &#39;Bearer &#39; + github_api_key,<br>    }<br>    response = requests.request(&quot;GET&quot;, url, headers=headers, data=payload)<br>    return json.loads(response.text)<br><br><br>def get_file_data(github_api_key, github_owner, github_repo, file_path):<br>    url = &quot;https://api.github.com/repos/&quot; + github_owner + &quot;/&quot; + github_repo + &quot;/contents/&quot; + file_path<br>    payload={}<br>    headers = {<br>    &#39;Authorization&#39;: &#39;Bearer &#39; + github_api_key<br>    }<br>    response = requests.request(&quot;GET&quot;, url, headers=headers, data=payload)<br>    return json.loads(response.text)<br><br><br>def readFiles(github_api_key, github_owner, github_repo, github_branch, viewId, apiKey):<br>    repo_files = getFiles(github_api_key, github_owner, github_repo, github_branch)<br>    headers = {<br>    &#39;X-GitHub-Api-Version&#39;: &#39;2022-11-28&#39;,<br>    &#39;Authorization&#39;: &#39;Bearer &#39; + github_api_key<br>    }<br>    for repo_file in repo_files[&#39;tree&#39;]:<br>        if repo_file[&#39;path&#39;].endswith(&#39;.csv&#39;):<br>            valid_file = get_file_data(github_api_key, github_owner, github_repo, repo_file[&#39;path&#39;])<br>            url = valid_file[&#39;download_url&#39;]<br>            req = requests.get(url, headers=headers)        <br>            print(url)<br>            print(req)<br>            if req.status_code == requests.codes.ok:<br>                generate_columns(viewId, apiKey, req.text)<br>                cs_with_path = add_pathtag_to_csv(req.text, valid_file[&#39;path&#39;])<br>                upload_file_into_gridly(cs_with_path, viewId, apiKey)<br>            else:<br>                print(&#39;Content was not found.&#39;)<br><br><br>def add_pathtag_to_csv(csv_string, path):<br>    # Parse the CSV string into a list of rows<br>    rows = list(csv.reader(csv_string.splitlines()))<br>    firstRow = True<br>    # Add a new column with the value 7 for all rows<br>    for row in rows:<br>        if firstRow:<br>            row.append(&#39;_pathTag&#39;)<br>            firstRow = False<br>        else:<br>            row.append(path)<br>    # Generate a new CSV string with the modified rows<br>    modified_csv_string = &quot;\n&quot;.join([&quot;\t&quot;.join(row) for row in rows])<br>    return modified_csv_string<br><br><br>def upload_file_into_gridly(file_content, viewId, apiKey):<br>    url = &quot;https://api.gridly.com/v1/views/&quot;+viewId+&quot;/import&quot;<br>    payload={}<br>    files=[<br>    (&#39;file&#39;,(&#39;Test Database NS_MT Post Edit_Default view.csv&#39;,file_content,&#39;text/csv&#39;))<br>    ]<br>    headers = {<br>    &#39;Authorization&#39;: &#39;ApiKey &#39; + apiKey<br>    }<br>    response = requests.request(&quot;POST&quot;, url, headers=headers, data=payload, files=files)<br><br>def generate_columns(view_id, apiKey, csv_file):<br>    reader = csv.DictReader(csv_file.splitlines())<br>    # Get the headers<br>    headers = reader.fieldnames<br><br><br>    for header in headers:<br>        url = &quot;https://api.gridly.com/v1/views/&quot;+view_id+&quot;/columns&quot;<br>        id = re.sub(&#39;[^0-9a-zA-Z]+&#39;, &#39;*&#39;, header)<br>        payload = json.dumps({<br>            &quot;id&quot;: id,<br>            &quot;isTarget&quot;: True,<br>            &quot;name&quot;: header,<br>            &quot;type&quot;: &quot;multipleLines&quot;<br>        })<br>        headers = {<br>        &#39;Authorization&#39;: &#39;ApiKey &#39; + apiKey,<br>        &#39;Content-Type&#39;: &#39;application/json&#39;<br>        }<br>        response = requests.request(&quot;POST&quot;, url, headers=headers, data=payload)<br><br><br>def get_files_from_github(event, context):<br>    gridly_api_key = event[&quot;gridly_api_key&quot;]<br>    view_id = event[&quot;view_id&quot;]<br>    github_owner = event[&quot;github_owner&quot;]<br>    github_token = event[&quot;github_token&quot;]<br>    github_repo = event[&quot;gitub_repo&quot;]<br>    github_branch = event[&quot;github_branch&quot;]<br>    readFiles(github_token, github_owner, github_repo, github_branch, view_id, gridly_api_key)</pre><h3>Push translated files back into GitHub</h3><ol><li>Export Grid as CSV from Gridly</li></ol><p>Export the whole Grid from Gridly in CSV format via the Gridly API export endpoint.</p><p>2. Split files by Path</p><p>Split the Grid data by Path to organize files as needed.</p><p>3. Get the file SHA on GitHub</p><p>The original file SHA is needed for the commit call. In this tutorial, we’re using a function that requires the file path to retrieve the data object of the file from GitHub. Then, we can use the returned data to commit the updated data.</p><p>4. Delete unnecessary headers from the CSV</p><p>Since the Path column isn’t present in the original file, remove it from the data collection commiting to GitHub.</p><p>5. Commit the updated and cleaned data</p><p>In the response body, provide the SHA of the original file and the content decoded as byte64 in UTF-8 format.</p><h3>Code example: pushing the changes back to GitHub</h3><pre>import base64<br>import io<br>import requests<br>import json<br>import csv<br>from io import StringIO<br><br>def get_file_data(github_api_key, github_owner, github_repo, file_path):<br>    url = &quot;https://api.github.com/repos/&quot; + github_owner + &quot;/&quot; + github_repo + &quot;/contents/&quot; + file_path<br>    payload={}<br>    headers = {<br>    &#39;Authorization&#39;: &#39;Bearer &#39; + github_api_key<br>    }<br>    response = requests.request(&quot;GET&quot;, url, headers=headers, data=payload)<br>    return json.loads(response.text)<br><br>def export_file_from_gridly(view_id, apikey):<br>    url = &quot;https://api.gridly.com/v1/views/&quot; + view_id + &quot;/export&quot;<br>    payload={}<br>    headers = {<br>    &#39;Authorization&#39;: &#39;ApiKey &#39; + apikey<br>    }<br>    response = requests.request(&quot;GET&quot;, url, headers=headers, data=payload)<br>    return response.text<br><br><br>def split_csv_by_path(csv_string):<br>    reader = csv.DictReader(csv_string.splitlines())<br>    rows = list(reader)<br>    # Create a dictionary of lists, with one list for each unique value in the given column<br>    csv_dict = {}<br>    for row in rows:<br>        if row[&#39;_pathTag&#39;] not in csv_dict:<br>            csv_dict[row[&#39;_pathTag&#39;]] = [row]<br>        else:<br>            csv_dict[row[&#39;_pathTag&#39;]].append(row)<br>    # Write each list of dictionaries to a separate CSV string<br>    csv_strings = {}<br>    fieldnames = [&#39;English&#39;, &#39;Swedish&#39;, &#39;Vietnamese&#39;, &#39;_recordId&#39;, &#39;_pathTag&#39;]<br>    for name, rows in csv_dict.items():<br>        # Use a StringIO object to write the CSV to a string<br>        sio = StringIO()<br>        writer = csv.DictWriter(sio, fieldnames=fieldnames, delimiter=&quot;\t&quot;)<br>        writer.writeheader()<br>        writer.writerows(rows)<br>        csv_strings[name] = sio.getvalue()<br>    return csv_strings<br><br>def delete_not_needed_headers(csv_string):<br>    csv_string_io = io.StringIO(csv_string)<br>    reader = csv.DictReader(csv_string_io, delimiter=&#39;\t&#39;)<br>    rows = [row for row in reader]<br>    column_to_delete = &#39;_pathTag&#39;<br>    for row in rows:<br>        del row[column_to_delete]<br>    output_string = io.StringIO()<br>    writer = csv.DictWriter(output_string, fieldnames=list(rows[0].keys()))<br>    writer.writeheader()<br>    for row in rows:<br>        writer.writerow(row)<br>    return output_string.getvalue()<br><br>def fetch_to_github_steps(github_api_key, github_owner, github_repo, view_id, api_key):<br>    files = split_csv_by_path(export_file_from_gridly(view_id, api_key))<br>    for name, csv_string in files.items():<br>        csv_string = delete_not_needed_headers(csv_string)<br>        file_data = get_file_data(github_api_key, github_owner, github_repo, name)<br>        commit_to_github(github_api_key, github_owner, github_repo, name, csv_string, file_data[&#39;sha&#39;])<br><br><br>def commit_to_github(github_api_key, github_owner, github_repo, file_path, content, sha):<br>    url = &quot;https://api.github.com/repos/&quot;+github_owner+&quot;/&quot; + github_repo + &quot;/contents/&quot; + file_path<br>    content = base64.b64encode(bytes(content, &#39;utf-8&#39;))<br>    print(content)<br>    payload = json.dumps({<br>    &quot;message&quot;: &quot;Update from Gridly&quot;,<br>    &quot;content&quot;: content.decode(&#39;utf-8&#39;),<br>    &quot;sha&quot;: sha<br>    })<br>    headers = {<br>    &#39;Authorization&#39;: &#39;Bearer &#39; + github_api_key,<br>    &#39;Content-Type&#39;: &#39;application/json&#39;<br>    }<br>    response = requests.request(&quot;PUT&quot;, url, headers=headers, data=payload)<br>    print(response.text)<br><br>def commit_files_to_github(event, context):<br>    gridly_api_key = event[&quot;gridly_api_key&quot;]<br>    view_id = event[&quot;view_id&quot;]<br>    github_owner = event[&quot;github_owner&quot;]<br>    github_token = event[&quot;github_token&quot;]<br>    github_repo = event[&quot;gitub_repo&quot;]<br>    github_branch = event[&quot;github_branch&quot;]<br>    fetch_to_github_steps(github_token, github_owner, github_repo, view_id, gridly_api_key)</pre><h3>Authorization</h3><h3>GitHub</h3><p>GitHub requires an API key to get and set data. In our examples, we’ve used the github_token variable to store that token. Here’s how to obtain your GitHub token:</p><ol><li>On GitHub, click your avatar in the top-right corner and select <strong>Settings</strong>.</li><li>In the left sidebar, click <strong>Developer settings</strong>.</li><li>Click on <strong>Personal access tokens</strong>.</li><li>Click <strong>Generate new token</strong>.</li><li>Give your token a descriptive name, select its scopes (permissions), then click Generate token. Select the <strong>repo </strong>option to give permission for your private and public repositories.</li></ol><p>Treat your API token like a password, as it allows access to your GitHub account and data. Grant only the minimum permissions necessary for the desired task.</p><h3>Gridly</h3><p>To use the Gridly Rest API, open the Grid that you’ll use for the connection. In the API section, you’ll find viewID and API key for your Grid.</p><h3>Set up AWS Lambda functions in Gridly</h3><p>As seen in the code examples, base calls initiate the whole process in both directions. The arguments of these base calls are event and context. The <a href="https://help.gridly.com/hc/en-us/articles/4409589480465-Using-Lambda-function">Gridly lambda script</a> places the payload into the event argument.</p><h3>How to create an automation in Gridly</h3><ol><li>Open your Grid and click the lightning-bolt Automations icon on the right side.</li><li>Click <strong>Add automation</strong>.</li><li>Name your automation.</li><li>Click <strong>Add Trigger</strong>.</li><li>Select the <strong>Trigger button clicked</strong> from the list.</li><li>Click <strong>Add Step</strong>.</li><li>Click <strong>Lambda Function</strong>.</li><li>Click <strong>Add Function</strong>.</li><li>Browse the ZIP file that contains the script.</li><li>Fill the form with the required data. Set the <strong>Handler name</strong> as the name of the function. In the sample code in this tutorial, the handler name is <em>get_files_from_github.</em></li><li>Click <strong>Add</strong>.</li><li>Create a JSON payload in the payload section with the following data:</li></ol><pre>{<br>  &quot;gridly_api_key&quot;:&quot;&quot;,<br>  &quot;view_id&quot;:&quot;&quot;,<br>  &quot;github_owner&quot;:&quot;&quot;,<br>  &quot;gitub_repo&quot;:&quot;&quot;,<br>  &quot;github_branch&quot;:&quot;&quot;,<br>  &quot;github_token&quot;:&quot;&quot;<br>}</pre><p>``<br>The <em>gridly_api_key</em> and <em>view_id</em> can be found in Gridly in the API Quickstart:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*gfLNCj-Oq6_HyZfPmLn44w.png" /></figure><p>The <em>github_owner</em> and <em>github_repo</em> can be found in the link of your GitHub repository. Consider the following repo link: <a href="https://github.com/norbertszolnoki/gridly-github-integration-testfiles">https://github.com/norbertszolnoki/gridly-github-integration-testfiles</a>. Here, <em>norbertszolnoki</em> is the owner and <em>gridly-github-integration-testfiles</em> is the repository.</p><p>The <em>github_branch</em> is a branch you would like to pull. Select <em>main</em> every repo has a main when they are created. For the <em>github_token</em>, refer to the <em>Authorization/GitHub</em> section of this tutorial.</p><p>Pushing the data back into GitHub uses the same payload. Enter <em>commit_files_to_github</em> for the Handler name when creating the action.</p><h3>Expanding this script</h3><p>If you have images or voice-overs in your GitHub repository, you can pull them into Gridly as well. Add an extra payload item that tells the script the header of the column containing the name of those files, and another payload item with the path of the files. Then, add a function that gets the files after the CSV import and adds them to the Grid: <a href="https://www.gridly.com/docs/api/#upload-file">https://www.gridly.com/docs/api/#upload-file</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1d57ea52cc9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>