DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > Beyond English: Supporting Multiple Languages in Puppet Modules

Beyond English: Supporting Multiple Languages in Puppet Modules

Puppet was built to output English, but that's about to change. Take a look at how you can have your modules support multiple languages.

Davin Hanlon user avatar by
Davin Hanlon
·
Oct. 16, 17 · DevOps Zone · Tutorial
Like (3)
Save
Tweet
3.37K Views

Join the DZone community and get the full member experience.

Join For Free

If your daily language isn't English, you've probably noticed that the output from supported Puppet modules is displayed in English — and only in English. That's about to change. We are now making changes so that other languages can be available on the Forge. This is part of our internationalization effort to support end users whose first language is not English.

If you're writing a module and you want to make it available in multiple languages, you need to decorate strings that are externalized — that is, displayed to the person using the module. I will illustrate how this works with the MySQL module, by using a solution based on RuboCop.

RuboCop

RuboCop is a static code analyzer that is used to enforce best-practice style guidelines documented in the Ruby Style Guide. It helps to keep code consistent and readable while supporting contributions from multiple authors. It can also be used to help developers identify syntactic errors. RuboCop runs against the Ruby code in a module — that is, against code in the lib/ folder. (Note that it does not run against Puppet DSL.) It is already enabled for Vox Pupuli modules and the RuboCop template was developed by the Puppet developer experience team for use in the Puppet Development Kit (PDK), and will become the default recommendation for new modules.

The various checks that RuboCop performs on code are known as “cops.” RuboCop allows custom “cops” to be defined. We are going to create a new custom cop that will identify strings that should be marked for translation in the module and decorate those strings, so they can be extracted for translation. The goal is to decorate all the warning and error strings that are displayed to the end user by the module.

How to Run RuboCop

RuboCop is run by typing the command the bundle exec rubocop command, as illustrated in the screenshot below, which runs the command for the contents of the ‘lib’ folder. This identifies strings that need to be decorated.

Image of How to run RuboCop

Is it also possible for RuboCop to auto-correct the strings that it finds. This can be performed by passing in the -a parameter, as illustrated below. This should be used with caution, as it’s noted as experimental.

Image of How to run RuboCop

How This Affects You

We are starting to externalize strings in the MySQL module, with the aim to add Japanese translations in the near future. Contributors to the MySQL module will notice that it conforms to the RuboCop configuration, as demonstrated by this pull request. RuboCop will now be run by Travis and available as a Rake task in the Puppet Spec Helper.

Next Steps

RuboCop with our custom cop will be enabled on other supported modules in the future in order to have their user-visible strings decorated for translation.

ENGLISH (programming language) Strings

Published at DZone with permission of Davin Hanlon, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Upsert in SQL: What Is an Upsert, and When Should You Use One?
  • Modern REST API Design Principles and Rules
  • Evolving Domain-Specific Languages
  • The Right Way to Hybridize Your Product Development Technique

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo