Giter Site home page Giter Site logo

shaydenofziger / skyux-scripts-translate Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 55 KB

PowerShell module for using Azure Cognitive Service's Translate API to auto-generate skyux resources.json files in different languages

License: MIT License

PowerShell 100.00%

skyux-scripts-translate's Introduction

Skyux.Translate PowerShell Module

This is a PowerShell module intended to be used to auto-generate Skyux Resource json files translations based on a source language file.

The source language file is usually 'src/assets/locales/resources_en_US.json' but the cmdlet is generic enough to work with any source language.

Usage

# Import the module for use at any location in the terminal
Import-Module .\Skyux.Translate.psm1

# These are the configuration values for the Azure Cognitive Services instance that can be created/configured via Azure Portal
$SubscriptionRegion = 'eastus2'
$SubscriptionKey = 'SuperSecretKey'

# The absolute path to the directory containing your 'resources_*_*.json' files
$PathToAssetsLocalesDirectory = 'D:\Repos\skyux-spa-signin\src\assets\locales\'

# Cognitive Services supports 'plain' and 'html' text translations.
# If any of your resource strings contain html tags, such as '<a href=...>',
# be sure to set this to 'html' so those attributes are not translated.
# If all of the values are plaintext, set the value to 'plain'.
$TextType = 'html'

# TargetLanguage and TargetCountryCode are specified here as examples.
# By default, SourceLanguage and SourceCountryCode are assumed to be 'en' and 'US' unless otherwise provided.
Invoke-SkyuxResourcesTranslation -TargetLanguage 'es' -TargetCountryCode 'US' -SubscriptionRegion $SubscriptionRegion -SubscriptionKey $SubscriptionKey -PathToAssetsLocalesDirectory $PathToAssetsLocalesDirectory

Limitations

At this time, Azure Cognitive Services has limited support for differentiation by Country Code (i.e. uk english vs us english). The 'TargetCountryCode' you provide to the cmdlet is currently only used for the output file naming.

Example output

See the files under the /locales directory at this location for example input/output. For the translations, the 'resources_en_US.json' file was used as the source, and the 'es', 'fr', and 'it' files were specified as the targets.

skyux-scripts-translate's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.