Translating Hubspot Articles
Project description
Hubspot-Article-Translator
Auto translation of Hubspot Knowledgebase Articles powered by Selenium
Important
This application only performs upserts to DRAFT articles. It will never modify an article that is published.
Demo Videos
How to use application (for users)
Getting all the article IDs
It would be time consuming to get all the article IDs from each page manually. Instead, navigate to the knowledge base articles page, then open the console and paste this command
[...document.querySelectorAll('[data-test-object-id]')].map(e => e.getAttribute('data-test-object-id')).join("|")
How to use module (for developers)
Ensure Chrome is installed on the machine executing the script, so selenium can leverage off of it
Configuring Translation APIs
AWS API
import boto3
from hubspot_article_translator import translation_manager, AWSTranslateClient
# Setup Translation Client/s
boto3.setup_default_session()
translation_manager.add_clients(
AWSTranslateClient(
aws_session=boto3.DEFAULT_SESSION
)
)
Azure API
from hubspot_article_translator import translation_manager, AzureTranslateClient
# Setup Translation Client/s
translation_manager.add_clients(
AzureTranslateClient(
key="<AZURE_TRANSLATE_KEY>",
location="<AZURE_TRANSLATE_LOCATION>",
endpoint="<AZURE_TRANSLATE_ENDPOINT>",
api_version="<AZURE_TRANSLATE_API_VERSION>"
)
)
Executing the translation workflow
import boto3
from selenium import webdriver
from hubspot_article_translator import State, workflow, translation_manager, AWSTranslateClient, AzureTranslateClient
if __name__ == "__main__":
# Create the selenium Chrome driver
driver = webdriver.Chrome()
# Execute the workflow, passing parameters into State object
workflow.execute(
driver=driver,
state=State(
# Your Hubspot Account Email
email="<HUBSPOT EMAIL>",
# Your Hubspot Account Password
password="<HUBSPOT PASSWORD>",
# 2FA code from Authenticator App
code="<HUBSPOT 2FA CODE>",
# List of article IDs to translate
article_ids=["<ID OF ARTICLE TO TRANSLATE>", ...],
# The ID of the knowledge base that the above articles are in
# the source language of articles
from_language="en",
# the languages each article will be translated to
# make sure key aligns with content language codes
# https://github.com/noodle-factory/Hubspot-Article-Translator/blob/master/hubspot_article_translator/translation/content_languages/content_languages.json
# make sure value is exactly the name of the language in Hubspot
to_languages={
"es": "Spanish",
"pt-pt": "Portuguese - Portugal",
"id": "Indonesian"
},
# Automatically publish the article once translation is done
# Note ensure that you have setup all the knowledge base category translations for each language...
# Otherwise you won't be able to publish the articles
auto_publish=True|False
)
)
# Close the selenium Driver
driver.quit()
Known Limitations
-
This hasn't been tested with other browsers, it will likely only work with Chrome currently
-
The account must be configured with 2FA through the authenticator app, and not a mobile phone number
-
The knowledge base articles must all be setup in English, as other articles will be translated from this
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for hubspot_article_translator-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | def18147f346c8f6b7c38fd189439d7592a817c3b949eef812322e4d3d602c35 |
|
MD5 | 76b2a84bb50c9b59f620bff7a90cd51a |
|
BLAKE2b-256 | be188ba073c973739dff7a8028f7149f9cddfb1ea8f31c74ea91385ad9c56ba0 |
Hashes for hubspot_article_translator-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 875fc12382efba413f809949f9a9c4fab25461c0d408bba9711f459c23a2dfa3 |
|
MD5 | b9bb718da8193cd929fc03110989e80d |
|
BLAKE2b-256 | 2a09ab75baae5ff195b86d09573d56c95773befab6b67ad5bd6ed4dff7a6ca3d |