### Install Smartling CLI from Source (Go) Source: https://github.com/smartling/smartling-cli/wiki/Installation Installs the Smartling CLI using the Go toolchain, fetching the latest version directly from its GitHub repository. This method requires Go to be installed on the system. ```bash go install github.com/Smartling/smartling-cli@latest ``` -------------------------------- ### Verify Smartling CLI Installation Source: https://github.com/smartling/smartling-cli/wiki/Installation Commands to verify the Smartling CLI installation by checking its version, displaying help information, and initializing the CLI configuration. These are essential post-installation steps. ```bash # Check version smartling-cli --version # Test basic functionality smartling-cli --help # Verify authentication setup smartling-cli init ``` -------------------------------- ### Install Legacy Smartling CLI v1.7 on Windows Source: https://github.com/smartling/smartling-cli/wiki/Installation Downloads a specific legacy version (1.7) of the Smartling CLI for Windows. This is intended only for use if required by existing workflows. ```bash curl --output smartling-cli.exe https://smartling-connectors-releases.s3.amazonaws.com/cli/smartling.windows-1.7.exe ``` -------------------------------- ### Install Legacy Smartling CLI v1.7 on Linux Source: https://github.com/smartling/smartling-cli/wiki/Installation Downloads a specific legacy version (1.7) of the Smartling CLI for Linux, makes it executable, and moves it to the system's binary path. Requires sudo privileges. ```bash curl --output smartling-cli https://smartling-connectors-releases.s3.amazonaws.com/cli/smartling.linux-1.7 \ && sudo chmod +x smartling-cli \ && sudo mv smartling-cli /usr/local/bin/ ``` -------------------------------- ### Install Smartling CLI in GitHub Actions Source: https://github.com/smartling/smartling-cli/wiki/Installation A GitHub Actions step to download, make executable, and move the Smartling CLI to the system path. This is suitable for integrating the CLI into CI/CD workflows. ```yaml - name: Install Smartling CLI run: | curl -L https://smartling-connectors-releases.s3.amazonaws.com/cli/smartling.linux \ -o smartling-cli chmod +x smartling-cli sudo mv smartling-cli /usr/local/bin/ ``` -------------------------------- ### Smartling CLI init command usage examples Source: https://github.com/smartling/smartling-cli/blob/master/docs/smartling-cli_init.md These examples demonstrate how to use the 'smartling-cli init' command. The first example shows a standard initialization to create a smartling.yml file, while the second illustrates a dry run to preview the configuration without making changes. ```bash # Create a configuration file with your Smartling API credentials: # This creates a smartling.yml file in your current directory with your project settings. # Note: Running init again will overwrite the existing configuration file. smartling-cli init # Dry run of init command without overwriting the existing configuration file. smartling-cli init --dry-run ``` -------------------------------- ### Install Smartling CLI on Linux Source: https://github.com/smartling/smartling-cli/wiki/Installation Downloads the latest stable Linux executable, makes it executable, and moves it to the system's binary path for global access. Requires sudo privileges for moving the file. ```bash curl --output smartling-cli https://smartling-connectors-releases.s3.amazonaws.com/cli/smartling.linux \ && sudo chmod +x smartling-cli \ && sudo mv smartling-cli /usr/local/bin/ ``` -------------------------------- ### Install Legacy Smartling CLI v2.1 on Linux Source: https://github.com/smartling/smartling-cli/wiki/Installation Downloads a specific older version (2.1) of the Smartling CLI for Linux, makes it executable, and places it in the system's binary path. Requires sudo privileges. ```bash curl --output smartling-cli https://github.com/Smartling/smartling-cli/releases/download/2.1/smartling.linux \ && sudo chmod +x smartling-cli \ && sudo mv smartling-cli /usr/local/bin/ ``` -------------------------------- ### List All Projects in Account Source: https://github.com/smartling/smartling-cli/wiki/Projects-command-examples Lists all projects within the Smartling account, displaying their IDs, names, and primary locales. This command helps users get an overview of their available projects. ```bash $ smartling-cli projects list 2f2xxxxx Sitecore Connector en-US 129xxxxx Wordpress Connector en 855xxxxx Drupal Connector en 7c7xxxxx Word files en ``` -------------------------------- ### Get Project Information Source: https://github.com/smartling/smartling-cli/wiki/Projects-command-examples Retrieves detailed information about a specific project, including its ID, account ID, name, locale, and status. This is useful for understanding the configuration and state of a project. ```bash $ smartling-cli projects info ID 2f2xxxxx ACCOUNT a3exxxxx NAME Test site LOCALE en-US: English (United States) STATUS active ``` -------------------------------- ### Install Legacy Smartling CLI v1.7 on macOS Source: https://github.com/smartling/smartling-cli/wiki/Installation Downloads a specific legacy version (1.7) of the Smartling CLI for macOS, makes it executable, and moves it to the system's binary path. Requires sudo privileges. ```bash curl --output smartling-cli https://smartling-connectors-releases.s3.amazonaws.com/cli/smartling.darwin-1.7 \ && sudo chmod +x smartling-cli \ && sudo mv smartling-cli /usr/local/bin/ ``` -------------------------------- ### Install Smartling CLI on Windows Source: https://github.com/smartling/smartling-cli/wiki/Installation Downloads the latest stable Windows executable for the Smartling CLI using curl. This command saves the executable to 'smartling-cli.exe' in the current directory. ```bash curl --output smartling-cli.exe https://smartling-connectors-releases.s3.amazonaws.com/cli/smartling.windows.exe ``` -------------------------------- ### Install Legacy Smartling CLI v2.1 on Windows Source: https://github.com/smartling/smartling-cli/wiki/Installation Downloads a specific older version (2.1) of the Smartling CLI for Windows using curl. This is useful for maintaining compatibility with older workflows. ```bash curl --output smartling-cli.exe https://github.com/Smartling/smartling-cli/releases/download/2.1/smartling.windows.exe ``` -------------------------------- ### Install Smartling CLI on macOS Source: https://github.com/smartling/smartling-cli/wiki/Installation Downloads the latest stable macOS executable, makes it executable, and moves it to the system's binary path for global access. Requires sudo privileges for moving the file. ```bash curl --output smartling-cli https://smartling-connectors-releases.s3.amazonaws.com/cli/smartling.darwin \ && sudo chmod +x smartling-cli \ && sudo mv smartling-cli /usr/local/bin/ ``` -------------------------------- ### Example: List All Projects (smartling-cli) Source: https://github.com/smartling/smartling-cli/blob/master/docs/smartling-cli_projects_list.md This example demonstrates how to list all available projects within your Smartling account using the 'smartling-cli projects list' command. No additional flags are required for a basic listing. ```bash smartling-cli projects list ``` -------------------------------- ### Install Smartling CLI in GitLab CI Source: https://github.com/smartling/smartling-cli/wiki/Installation GitLab CI configuration to download and make the Smartling CLI executable, then add the current directory to the PATH. Ensures the CLI is available in CI jobs. ```yaml before_script: - curl -L https://smartling-connectors-releases.s3.amazonaws.com/cli/smartling.linux -o smartling-cli - chmod +x smartling-cli - export PATH="$PWD:$PATH" ``` -------------------------------- ### Install Legacy Smartling CLI v2.1 on macOS Source: https://github.com/smartling/smartling-cli/wiki/Installation Downloads a specific older version (2.1) of the Smartling CLI for macOS, makes it executable, and places it in the system's binary path. Requires sudo privileges. ```bash curl --output smartling-cli https://github.com/Smartling/smartling-cli/releases/download/2.1/smartling.darwin \ && sudo chmod +x smartling-cli \ && sudo mv smartling-cli /usr/local/bin/ ``` -------------------------------- ### Install Smartling CLI in Jenkins Pipeline Source: https://github.com/smartling/smartling-cli/wiki/Installation A Jenkins pipeline stage to download and make the Smartling CLI executable. This allows Jenkins jobs to utilize the Smartling CLI for automation tasks. ```groovy pipeline { agent any stages { stage('Install CLI') { steps { sh 'curl -L https://smartling-connectors-releases.s3.amazonaws.com/cli/smartling.linux -o smartling-cli' sh 'chmod +x smartling-cli' } } } } ``` -------------------------------- ### Troubleshoot Smartling CLI Permissions (macOS/Linux) Source: https://github.com/smartling/smartling-cli/wiki/Installation Provides commands to fix common permission issues on macOS and Linux when installing the Smartling CLI. This includes making the binary executable and correcting ownership if necessary. ```bash # If binary is not executable chmod +x smartling-cli # If moved to system path fails sudo chown $(whoami) /usr/local/bin/smartling-cli ``` -------------------------------- ### Download Properties Files Locally Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Downloads all files matching the pattern '*.properties' from the configured Smartling project to the local directory. It displays the progress of each download. ```bash $ smartling-cli files pull **ep?.properties --source downloaded files/ep1.properties 0% downloaded files/ep5.properties 0% downloaded files/ep2.properties 0% ``` -------------------------------- ### Run Smartling CLI using Docker Source: https://github.com/smartling/smartling-cli/wiki/Installation Pulls the latest official Smartling CLI Docker image and demonstrates how to run a command, mounting the current directory as a volume for file access. This method isolates the CLI environment. ```bash # Pull the official image docker pull smartling/cli:latest # Run with volume mount for local files docker run -v $(pwd):/workspace smartling/cli:latest files list ``` -------------------------------- ### Display Source Locale Source: https://github.com/smartling/smartling-cli/wiki/Projects-command-examples Shows the source locale of a project. This can be displayed with its full description or in a short format using the `-s` or `--short` option. ```bash $ smartling-cli projects locales --source en-US English (United States) ``` ```bash $ smartling-cli projects locales --source -s en-US ``` -------------------------------- ### List All Target Locales Source: https://github.com/smartling/smartling-cli/wiki/Projects-command-examples Displays all target locales associated with a project, including their locale IDs and descriptions. This helps in identifying all available language options for translation. ```bash $ smartling-cli projects locales zh-CN Chinese (Simplified) true en-AU English (Australia) true fr-FR French (France) true de-DE German (Germany) true it-IT Italian (Italy) true ru-RU Russian true es Spanish (International) true ``` -------------------------------- ### Manage Projects with Smartling Go Service API Source: https://context7.com/smartling/smartling-cli/llms.txt Contains Go code examples for managing Smartling projects. This includes initializing the projects service, retrieving project information, listing all projects, and listing project locales. ```go package projects import ( "github.com/Smartling/smartling-cli/services/projects" "github.com/Smartling/smartling-cli/services/helpers/config" sdk "github.com/Smartling/api-sdk-go" ) // Initialize projects service cfg := config.Config{ UserID: "abc123xyz", Secret: "your-token-secret", ProjectID: "proj456", AccountID: "acc123", } apiClient := sdk.NewHttpAPIClient(cfg.UserID, cfg.Secret) err := apiClient.Authenticate() if err != nil { panic(err) } svc := projects.NewService(cfg, apiClient) // Get project information err = svc.RunInfo() if err != nil { // Handle error - outputs to stdout } // List all projects err = svc.RunList(false) // false = full format, true = short format if err != nil { // Handle error } // List project locales localesParams := projects.LocalesParams{ Format: "{{.LocaleID}}\t{{.Description}}", } err = svc.RunLocales(localesParams) if err != nil { // Handle error } ``` -------------------------------- ### Get Files Status Overview Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Fetches a status report for files in the Smartling project, indicating their localization state (e.g., missing, translated percentage) for different locales. The output includes locale information, translation status, and counts for strings and words. ```bash $ smartling-cli files status config/locales/account.en.yml en-US missing source 5 5 config/locales/account.en_be-BY.yml be-BY missing 0% 0 0 config/locales/account.en_de-DE.yml de-DE missing 100% 5 5 config/locales/account.en_en-AU.yml en-AU missing 0% 0 0 config/locales/account.en_es.yml es missing 0% 0 0 config/locales/account.en_es-ES.yml es-ES missing 100% 5 5 config/locales/account.en_fr-FR.yml fr-FR missing 100% 5 5 config/locales/account.en_it-IT.yml it-IT missing 0% 0 0 config/locales/account.en_nl-NL.yml nl-NL missing 100% 5 5 config/locales/account.en_ru-RU.yml ru-RU missing 0% 0 0 config/locales/account.en_zh-CN.yml zh-CN missing 0% 0 0 test2.json en-US missing source 1 4 test2_be-BY.json be-BY missing 0% 0 0 test2_it-IT.json it-IT missing 0% 0 0 test2_zh-CN.json zh-CN missing 0% 0 0 test2_ru-RU.json ru-RU missing 100% 1 4 test2_es.json es missing 100% 1 4 test2_de-DE.json de-DE missing 0% 0 0 test2_en-AU.json en-AU missing 0% 0 0 test2_es-ES.json es-ES missing 0% 0 0 test2_fr-FR.json fr-FR missing 0% 0 0 .... ``` -------------------------------- ### List All Files in a Project Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Lists all files currently present in the configured Smartling project. The output includes the file URI, last modified timestamp, and file type. ```bash $ smartling-cli files list /files/ep1.properties 2016-08-04T08:18:14Z javaProperties /files/ep2.properties 2016-08-04T08:30:44Z javaProperties /files/ep5.properties 2016-08-10T14:04:45Z javaProperties /files/example.STRINGSDICT 2016-08-26T08:47:54Z stringsdict /files/Localizable.stringsdict 2016-08-26T08:47:54Z stringsdict /files/Localizable2.stringsdict 2016-09-23T16:22:49Z stringsdict .... ``` -------------------------------- ### Smartling CLI: Project Management Source: https://github.com/smartling/smartling-cli/wiki/Home Provides examples of commands for managing Smartling projects. These include retrieving project information, listing all target locales associated with a project, and listing all projects within the Smartling account. ```bash # View project information smartling-cli projects info # List all target locales smartling-cli projects locales # List all projects in your account smartling-cli projects list ``` -------------------------------- ### Download Only Source Files Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Downloads only the original source files from Smartling, without any translations. This is useful for backup purposes or when you need to re-process the original content. ```bash $ smartling-cli files pull **test.xml --source downloaded files\test.xml 0% downloaded test.xml 0% downloaded master\test.xml 0% ``` -------------------------------- ### Initialize and Validate Smartling Configuration (Go) Source: https://context7.com/smartling/smartling-cli/llms.txt Shows how to initialize and validate Smartling configuration files using the Initialization Service. This service generates and tests connection to the Smartling API. It takes a configuration struct with file path and API credentials, and a boolean to determine if it's a dry run. The `RunInit` function returns an error if the configuration process fails, otherwise, it provides output on the setup process and connection status. ```go package initialize import ( "github.com/Smartling/smartling-cli/services/init" "github.com/Smartling/smartling-cli/services/helpers/config" sdk "github.com/Smartling/api-sdk-go" ) // Initialize configuration service cfg := config.Config{ Path: "./smartling.yml", UserID: "", // Will be prompted Secret: "", // Will be prompted ProjectID: "", // Will be prompted AccountID: "", // Will be prompted (optional) } svc := initialize.NewService(cfg, nil) // Run interactive configuration // This will prompt for credentials and test connection err := svc.RunInit(false) // false = write file, true = dry run if err != nil { // Handle error } // Dry run (preview only) err = svc.RunInit(true) if err != nil { // Handle error } // Output: // Generating ./smartling.yml... // // Smartling API V2.0 User Identifier: abc123 // Smartling API V2.0 Token Secret: ******** // Account ID (optional): acc456 // Project ID: proj789 // Testing connection to Smartling API... // Connection is successful. ``` -------------------------------- ### Download Translated Files by Locale Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Downloads translated files for specified locales using file masks. This command allows you to selectively download translations for the languages you need. ```bash $ smartling-cli files pull '**test.xml' -l es -l fr-FR downloaded test_es.xml 0% downloaded files/test_es.xml 0% downloaded master/test_es.xml 0% downloaded files/test_fr-FR.xml 0% downloaded test_fr-FR.xml 0% downloaded master/test_fr-FR.xml 0% ``` -------------------------------- ### List Files by Mask and Short Output Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Retrieves a list of file URIs from the Smartling project that match a specified wildcard mask. The `--short` option limits the output to only display the file URIs. ```bash $ smartling-cli files list '**test.xml' --short /files/placeholder_test.xml /files/test.xml master/test.xml test.xml ``` -------------------------------- ### List Only Locale IDs (Short Form) Source: https://github.com/smartling/smartling-cli/wiki/Projects-command-examples Lists only the locale IDs for a project, using the short form output. The `-s` or `--short` options can be used to simplify the output to just the locale codes. ```bash $ smartling-cli projects locales -s zh-CN nl-NL de-DE ``` -------------------------------- ### Example Usage of File Renaming Script Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples This is an example of how to execute the file renaming script. It demonstrates calling the script with 'ja' as the source locale, 'ja_jp' as the destination locale, and 'dryrun' mode to show the intended renames without actually performing them. ```shell $ ./rename-files.sh ja ja_jp dryrun Rename file test1_en.xml test1_en-us.xml Rename file /content/geometrixx/en/products/circle-35202_en.xml /content/geometrixx/en/products/circle-35202_en-us.xml !!!!!No files were renamed!!!!! It was dryrun mode ``` -------------------------------- ### List Files with Custom Output Format Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Lists files in a Smartling project using a custom output format and a more complex mask. The `--format` flag allows specifying the desired structure of the output, using Go template syntax. ```bash $ smartling-cli files list '**{id,_}**.xml' --format='{{.FileType}}\t{{.FileURI}}\n' xml /files/placeholder_test.xml xml new_test_file.xml xml test-client-id.xml xml test_dropbox_variants_ns1.xml xml test_dropbox_variants_ns2.xml xml test_keys.xml ``` -------------------------------- ### Specify Configuration File Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Explicitly tells the Smartling CLI to use a specific configuration file for its operations. This is useful when the configuration file is not named `smartling.yml` or is located in a different directory. ```bash $ smartling-cli -c smartling.yml files push '**.{txt,md}' ``` -------------------------------- ### Display Enabled Target Locales with Custom Format Source: https://github.com/smartling/smartling-cli/wiki/Projects-command-examples Displays only the enabled target locales for a project using custom output formatting with Golang templates. This allows for selective display of locale information, such as only showing the LocaleID. ```bash $ smartling-cli projects locales --format='{{if .Enabled}}{{.LocaleID}}{{end}}\n' zh-CN nl-NL de-DE ``` -------------------------------- ### Advanced Filtering with Pipes and JSON Output Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Demonstrates using pipes to combine the CLI with tools like `jq` for advanced data processing. This example filters the JSON output of language detection to display only files with the language code 'es'. ```bash $ smartling-cli mt detect "document*.txt" --output json | jq '.[] | select(.Language == "es") | {File, Language}' { "File": "document1.txt", "Language": "es" } ``` -------------------------------- ### Download Files Using Pipes and Filters Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Downloads files by first listing files matching a pattern, then filtering the list using `grep` to select files with specific characters in their URI, and finally piping the filtered list to the download command. This demonstrates a powerful workflow for targeted downloads. ```bash $ smartling-cli files list '**test.*' --short | grep '[_-]' | smartling-cli files pull --source downloaded content/dam/geometrixx/portraits/yolanda_huggins.jpg-65359_de.xml 0% downloaded content/geometrixx-media/en-14306_de.xml 0% downloaded content/dam/geometrixx/portraits/scott_reynolds.jpg-65359_de.xml 0% downloaded content/geometrixx-outdoors/en-96925_de.xml 0% downloaded content/geometrixx/en-31001_de.xml 0% ``` -------------------------------- ### Smartling CLI: Advanced Usage - Branching and Versioning Source: https://github.com/smartling/smartling-cli/wiki/Home Illustrates how to manage file versions and organization using branch prefixes with the Smartling CLI. Examples cover manual branch naming and automatic Git branch detection for file uploads. ```bash # Manual branch naming smartling-cli files push "**/*.txt" --branch "feature-branch" # Automatic Git branch detection smartling-cli files push "**/*.txt" --branch "@auto" ``` -------------------------------- ### Upload Single File Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Uploads a single file to Smartling for translation. The command automatically detects the file type. This is the most basic upload command. ```bash $ smartling-cli files push my-file.txt ``` -------------------------------- ### Detect Language for Multiple Files Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Detects languages for multiple files simultaneously using wildcards. The command lists each file and its corresponding detected language. ```bash $ smartling-cli mt detect "document*.txt" document1.txt es document2.txt fr ``` -------------------------------- ### Upload Single File with URI Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Uploads a single file to Smartling while specifying a custom URI for the file within Smartling. This allows for more organized file management in the Smartling platform. ```bash $ smartling-cli files push my-file.txt /my/super/file.txt ``` -------------------------------- ### Shell Script to Rename Files with Smartling CLI Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples This shell script renames files based on source and destination locales. It uses `smartling-cli files list` to get a list of files, `grep` to filter by the source locale suffix, and `sed` to construct the new filename. It supports a 'dryrun' mode to preview changes before applying them with `smartling-cli files rename`. ```shell #!/bin/sh die () { echo >&2 "$@" exit 1 } [ "$#" -ge 2 ] || die "2 argument are required, $# provided" srcLocale=$1 dstLocale=$2 mode=${3:-"dryrun"} ./smartling-cli files list -s | grep -e "_$srcLocale.xml" | while read -r oldFileName do # newFileName=${oldFileName/_$srcLocale.xml/_$dstLocale.xml} newFileName=$(echo $oldFileName | sed "s/_$srcLocale.xml/_$dstLocale.xml/g") echo -e "Rename file\n\t$oldFileName\n\t$newFileName" if [[ $mode == "apply" ]]; then ./smartling-cli files rename "$oldFileName" "$newFileName" fi done if [[ $mode == "apply" ]]; then echo "=====All files were renamed=====" else echo "!!!!!No files were renamed!!!!! It was dryrun mode" fi ``` -------------------------------- ### Delete Files by Mask Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Deletes all files within the Smartling project that match a specified wildcard pattern. The example shows deleting all files under the 'master' branch. ```bash $ smartling-cli files delete 'master/**' master/test.xml deleted ``` -------------------------------- ### Smartling CLI Directory Flag Update (Bash) Source: https://github.com/smartling/smartling-cli/wiki/Home Illustrates the change in the Smartling CLI's directory flag from `-d, --directory` to `--operation-directory` starting from version 2.1. It provides a `sed` command example to help automate the update of this flag in existing scripts. ```bash # Before (v2.0 and earlier) smartling-cli -d /path/to/project [command] # After (v2.1+) smartling-cli --operation-directory /path/to/project [command] # Script update example sed 's/--directory/--operation-directory/g' your-script.sh sed 's/-d /--operation-directory /g' your-script.sh ``` -------------------------------- ### Upload with Branching/Versioning Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Uploads files and assigns them to a specific branch or version within Smartling using the --branch option. This is crucial for managing different versions of content or for parallel development workflows. ```bash $ smartling-cli files push '**.txt' -b 'testing' testing/test.txt new [3 strings 28 words] ``` ```bash $ smartling-cli files push '**.txt' --branch '@auto' * 2017-06-27 16:20:54 [INFO] autodetected branch name: master master/test.txt new [3 strings 28 words] ``` -------------------------------- ### Manage Files with Smartling Go Service API Source: https://context7.com/smartling/smartling-cli/llms.txt Provides Go code examples for interacting with the Smartling Files Service. This includes initializing the service, pushing files, pulling translations, checking file status, listing, deleting, and renaming files. ```go package files import ( "context" "github.com/Smartling/smartling-cli/services/files" "github.com/Smartling/smartling-cli/services/helpers/config" sdk "github.com/Smartling/api-sdk-go" batchapi "github.com/Smartling/api-sdk-go/api/batches" ) // Initialize files service cfg := config.Config{ UserID: "abc123xyz", Secret: "your-token-secret", ProjectID: "proj456", Threads: 4, } apiClient := sdk.NewHttpAPIClient(cfg.UserID, cfg.Secret) err := apiClient.Authenticate() if err != nil { panic(err) } // Get file-specific configuration fileConfig, err := cfg.GetFileConfig("src/app.json") if err != nil { panic(err) } // Create batch API client batchApi := batchapi.NewBatchClient(apiClient, cfg.ProjectID) svc := files.NewService(apiClient, batchApi, cfg, fileConfig) // Push files to Smartling ctx := context.Background() pushParams := files.PushParams{ File: "src/app.json", Branch: "main", Locales: []string{"fr-FR", "de-DE"}, Authorize: true, Directory: ".", FileType: "json", Directives: map[string]string{"string_format": "icu"}, JobIDOrName: "Website Update Q4", } err = svc.RunPush(ctx, pushParams) if err != nil { // Handle error } // Pull translated files pullParams := files.PullParams{ URI: "src/app.json", Format: "translations/{{.Locale}}/{{name .FileURI}}{{ext .FileURI}}", Directory: "./build", Source: false, Locales: []string{"fr-FR", "de-DE"}, Progress: "90", Retrieve: "published", } err = svc.RunPull(pullParams) if err != nil { // Handle error } // Get file status statusParams := files.StatusParams{ URI: "src/app.json", Directory: "./translations", Format: "{{.Locale}}/{{name .FileURI}}{{ext .FileURI}}", } err = svc.RunStatus(statusParams) if err != nil { // Handle error } // List files err = svc.RunList("{{.FileURI}}\t{{.FileType}}", false, "src/**/*.json") if err != nil { // Handle error } // Delete file err = svc.RunDelete("/src/old-file.json") if err != nil { // Handle error } // Rename file err = svc.RunRename("/src/old.json", "/src/new.json") if err != nil { // Handle error } ``` -------------------------------- ### Get Smartling Project Information Source: https://context7.com/smartling/smartling-cli/llms.txt Displays detailed information about the current Smartling project, including its ID, account UID, name, default locale, and status. ```bash # Show project details smartling-cli projects info ``` -------------------------------- ### Install Smartling CLI Bash Autocompletion Permanently on macOS Source: https://github.com/smartling/smartling-cli/blob/master/docs/smartling-cli_completion_bash.md This command installs the smartling-cli bash autocompletion script permanently on macOS systems using Homebrew. It redirects the script output to a file in the Homebrew-managed bash completion directory. A new shell session is necessary for activation. Ensure 'bash-completion' is installed. ```bash smartling-cli completion bash > $(brew --prefix)/etc/bash_completion.d/smartling-cli ``` -------------------------------- ### Install Smartling CLI Bash Autocompletion Permanently on Linux Source: https://github.com/smartling/smartling-cli/blob/master/docs/smartling-cli_completion_bash.md This command installs the smartling-cli bash autocompletion script permanently on Linux systems. It redirects the script output to a file within the /etc/bash_completion.d/ directory. A new shell session is required for the changes to take effect. The 'bash-completion' package is a prerequisite. ```bash smartling-cli completion bash > /etc/bash_completion.d/smartling-cli ``` -------------------------------- ### Detect Language for Files from a Folder Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Detects languages for all files with a specific extension within a given directory. The `--input-directory` option specifies the folder to scan for files. ```bash $ smartling-cli mt detect "*.txt" --input-directory ./documents/ documentA.txt en documentB.txt fr ``` -------------------------------- ### Upload Files by Mask Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Uploads multiple files matching a specific pattern (mask) from the local directory, including subdirectories. Shell expansion is prevented by using single quotes around the mask. ```bash $ smartling-cli files push '**.txt' ``` -------------------------------- ### Translate Multiple Files with Auto-Detected Source Language Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Translates multiple files to a specified target locale using wildcards. The source language for each file is automatically detected. ```bash $ smartling-cli mt translate "document*.txt" -l es-ES document1_es-ES.txt document2_es-ES.txt ``` -------------------------------- ### Upload with Smartling Directives Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Uploads a JSON file and applies specific Smartling directives to control parsing behavior, such as string capture paths and instructions. This allows for fine-grained control over how Smartling processes the file content. ```bash $ smartling-cli files push custom.json --directive translate_paths='{"path":"*/string","key":"{*}/string","instruction":"*/instruction"}' ``` -------------------------------- ### Smartling CLI: Advanced Usage - Pattern Matching Source: https://github.com/smartling/smartling-cli/wiki/Home Explains the use of glob patterns for performing bulk operations on files with the Smartling CLI. Examples show how to push all JSON files in subdirectories, specific file types, and files matching a naming convention. ```bash # All JSON files in subdirectories smartling-cli files push "**/*.json" # Specific file types smartling-cli files push "**/*.{json,xml,properties}" # Files matching naming convention smartling-cli files push "**/messages_*.properties" ``` -------------------------------- ### Translate File with Auto-Detected Source Language Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Translates a file to a specified target locale. If the source locale is omitted, the CLI automatically detects the source language of the file. ```bash $ smartling-cli mt translate document1.txt --target-locale es-ES document1_es-ES.txt ``` -------------------------------- ### Delete All Files in a Specific Project Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Deletes all files in a specified Smartling project. This is achieved by first listing all files in the target project and then piping that list to the delete command, specifying the same target project. ```bash $ smartling-cli files list -s -p 2a1xxxxxx | smartling-cli files delete - -p 2a1xxxxxx 27 Words To Learn Before You Visit Hawaii.docx deleted .... ``` -------------------------------- ### Rename a File Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Renames a file within the Smartling project from a specified old name to a new name. This command facilitates updating file names directly in the Smartling environment. ```bash $ smartling-cli files rename test.json test-rename.json ``` -------------------------------- ### Download translated files for specific locales using smartling-cli Source: https://github.com/smartling/smartling-cli/blob/master/docs/smartling-cli_files_pull.md This example demonstrates how to download all JSON files matching the pattern '**/*.json' for the 'fr-FR' and 'de-DE' locales from a Smartling project. ```bash smartling-cli files pull "**/*.json" --locale fr-FR --locale de-DE ``` -------------------------------- ### Translate Files to Multiple Target Locales and Output Directory Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Translates files to multiple target locales and saves the translated files into a specified output directory. The `--output-directory` option organizes the translated files. ```bash $ smartling-cli mt translate "document*.txt" -l es -l fr --output-directory ./translations document1_es,fr.txt document2_es,fr.txt $ ls ./translations/ document1_es.txt document1_fr.txt document2_es.txt document2_fr.txt ``` -------------------------------- ### Smartling CLI: Basic Commands Source: https://github.com/smartling/smartling-cli/wiki/Home Demonstrates fundamental Smartling CLI commands for initialization, file upload, and accessing help. The `init` command sets up the configuration file, while `--help` flags provide command-specific assistance. ```bash smartling-cli init smartling-cli --help smartling-cli files push --help smartling-cli mt translate --help ``` -------------------------------- ### Smartling Configuration File Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Defines file type overrides and other settings in a YAML configuration file. The Smartling CLI can automatically detect and use a `smartling.yml` file in the current directory, or it can be specified explicitly. ```yaml # authentication parameters files: "**.md": push: type: "plaintext" ``` -------------------------------- ### Partial File Type Override via Config Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Uploads files with different extensions, overriding the file type for specific extensions using a configuration file. This allows for consistent handling of file types across multiple uploads. ```bash $ smartling-cli files push '**.{txt,md}' ``` -------------------------------- ### Use Different Output Formats for Language Detection Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Allows customization of the output format for language detection results. The `--output table` option presents the information in a clear, tabular format, including file details and detection status. ```bash $ smartling-cli mt detect "document*.txt" --output table ┌─────────────┬─────────┬────┬─────────┬──────┬─────────┬────────┐ │File │Name │Ext │Directory│Upload│Detect │Language│ ├─────────────┼─────────┼────┼─────────┼──────┼─────────┼────────┤ │document1.txt│document1│.txt│. │✓ │COMPLETED│es │ │document2.txt│document2│.txt│. │✓ │COMPLETED│fr │ └─────────────┴─────────┴────┴─────────┴──────┴─────────┴────────┘ ``` -------------------------------- ### Upload Properties Files to Another Project Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Uploads all local files matching the pattern '*.properties' into a specified target Smartling project. It reports the status and content count (strings, words) for each uploaded file. Different credentials can be used for the target project if it belongs to a different account. ```bash $ smartling-cli files push **.properties -p 129xxxxx files/ep1.properties new [1 strings 2 words] files/ep2.properties new [1 strings 2 words] files/ep5.properties new [1 strings 3 words] ``` -------------------------------- ### Detect File Language Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Detects the language of a given file. The output includes the filename and its detected locale code. The `--short` option can be used to output only the locale code, which is useful for scripting. ```bash $ smartling-cli mt detect document1.txt document1.txt es ``` ```bash $ smartling-cli mt detect document1.txt --short es ``` -------------------------------- ### Override File Type Detection Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Explicitly specifies the file type for content parsing when automatic detection is insufficient. This ensures correct parsing, especially for structured formats like JSON. ```bash $ smartling-cli mt detect "*.json" --type json document.json fr ``` -------------------------------- ### Translate File with Explicit Source and Target Languages Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Translates a file by explicitly specifying both the source and target locales. This is useful when automatic detection might be inaccurate or when translating between specific language pairs. ```bash $ smartling-cli mt translate document1.txt --source-locale en --target-locale es-ES document1_es-ES.txt ``` -------------------------------- ### Setup persistent zsh autocompletion on Linux Source: https://github.com/smartling/smartling-cli/blob/master/docs/smartling-cli_completion_zsh.md This command sets up persistent zsh autocompletion for smartling-cli on Linux by saving the completion script to the zsh site-functions directory. This ensures autocompletion is available in all new shell sessions after execution. ```bash smartling-cli completion zsh > "${fpath[1]}/_smartling-cli" ``` -------------------------------- ### Setup persistent zsh autocompletion on macOS Source: https://github.com/smartling/smartling-cli/blob/master/docs/smartling-cli_completion_zsh.md This command sets up persistent zsh autocompletion for smartling-cli on macOS using Homebrew's prefix to locate the site-functions directory. The completion script is saved to enable autocompletion in all new shell sessions. ```bash smartling-cli completion zsh > $(brew --prefix)/share/zsh/site-functions/_smartling-cli ``` -------------------------------- ### Translate Files from a Source Folder to an Output Folder Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples Translates files located in a specified input directory to multiple target locales and saves them into a separate output directory. This facilitates batch translation of files organized within specific folders. ```bash $ smartling-cli mt translate "*.txt" -l es -l fr --input-directory ./documents/ --output-directory ./translations/ documentA_es,fr.txt ``` -------------------------------- ### Override File Type Upload Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Uploads a file and explicitly sets its file type, overriding any automatic detection. This is useful when the file extension does not accurately represent its content type (e.g., uploading a Markdown file as plain text). ```bash $ smartling-cli files push README.md --type plaintext README.md overwritten [3 strings 28 words] ``` -------------------------------- ### Delete Files from a List using Pipes Source: https://github.com/smartling/smartling-cli/wiki/Files-command-examples Deletes files from a Smartling project based on a list provided in a text file. The content of the file is piped as input to the delete command, with each line representing a file URI to be deleted. The '-' argument signifies reading from standard input. ```bash $ cat files-list.txt | smartling-cli files delete - /files/placeholder_test.xml deleted /files/test.xml deleted test.xml deleted ``` -------------------------------- ### smartling-cli init command execution Source: https://github.com/smartling/smartling-cli/blob/master/docs/smartling-cli_init.md This snippet shows the basic syntax for executing the 'smartling-cli init' command, which interactively creates a configuration file. It can accept flags to pre-fill configuration values or perform a dry run. ```bash smartling-cli init [flags] ``` -------------------------------- ### Initialize Smartling CLI Configuration Source: https://context7.com/smartling/smartling-cli/llms.txt Generates an interactive `smartling.yml` configuration file. It prompts the user for API credentials (User ID, Secret) and optional project settings (Account ID, Project ID). A dry-run option allows previewing the configuration without writing to a file. ```bash # Create configuration file interactively smartling-cli init # Dry run - display configuration without writing file smartling-cli init --dry-run # The tool will prompt for: # - User ID (API identifier) # - Secret (API token) # - Account ID (optional) # - Project ID # Example output: # Generating smartling.yml... # # Smartling API V2.0 User Identifier: abc123xyz # Smartling API V2.0 Token Secret: ******** # Account ID (optional): acc123 # Project ID: proj456 # Testing connection to Smartling API... # Connection is successful. ``` -------------------------------- ### List Accessible Smartling Projects Source: https://context7.com/smartling/smartling-cli/llms.txt Displays all Smartling projects accessible with the current credentials. Supports a short format to list only project IDs. ```bash # List all projects smartling-cli projects list # List in short format (IDs only) smartling-cli projects list --short ``` -------------------------------- ### Smartling CLI: File Operations Source: https://github.com/smartling/smartling-cli/wiki/Home Illustrates various file management operations using the Smartling CLI, including uploading single and multiple files with pattern matching, downloading translated files for specific locales, listing project files, and checking file status. ```bash # Upload files to a translation job smartling-cli files push my-file.txt --job "Website Update" --authorize # Upload multiple files with pattern matching smartling-cli files push "src/**/*.json" --job "App Localization" # Download translated files smartling-cli files pull "**/*.json" --locale fr-FR --locale de-DE # List project files smartling-cli files list # Check file status across locales smartling-cli files status ``` -------------------------------- ### Generate Bash Autocompletion Script for Smartling CLI Source: https://github.com/smartling/smartling-cli/blob/master/docs/smartling-cli_completion_bash.md This command generates the bash autocompletion script for the smartling-cli. It requires the 'bash-completion' package to be installed. The output can be sourced in the current shell or redirected to a file for persistent loading. ```bash smartling-cli completion bash ``` -------------------------------- ### Smartling CLI: Advanced Usage - Global Options Source: https://github.com/smartling/smartling-cli/wiki/Home Demonstrates how to override default configuration settings using global command-line flags. This allows for dynamic adjustment of project ID, account ID, and configuration file path for specific commands. ```bash smartling-cli files list \ --project "PROJECT_ID" \ --account "ACCOUNT_ID" \ --config "/path/to/config.yml" ``` -------------------------------- ### Conditional Translation Based on Detected Language Source: https://github.com/smartling/smartling-cli/wiki/MT-command-examples A bash script that detects the language of a file and conditionally translates it. If the detected language is English, it translates to French; otherwise, if it's French, it translates to English. ```shell #!/bin/bash detected=$(smartling-cli mt detect test.txt --short) if [[ "$detected" == "en" ]]; then smartling-cli mt translate test.txt --source-locale en --target-locale fr-FR elif [[ "$detected" =~ ^fr(-FR)?$ ]]; then smartling-cli mt translate test.txt --source-locale "$detected" --target-locale en fi ``` -------------------------------- ### List Files in Smartling Project Source: https://context7.com/smartling/smartling-cli/llms.txt Displays files within a Smartling project, with options for various output formats including URIs only or custom fields. Supports pattern matching for file selection. ```bash # List all files smartling-cli files list # List with short format (URIs only) smartling-cli files list --short # List specific pattern smartling-cli files list "src/**/*.json" # List with custom format smartling-cli files list --format "{{.FileURI}}\t{{.LastUploaded}}\t{{.FileType}}" ```