Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 53525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:04:37+00:00 2026-05-10T17:04:37+00:00

A while back I was reading the W3C article on ‘ Re-using Strings in

  • 0

A while back I was reading the W3C article on ‘Re-using Strings in Scripted Content‘, which contains some useful advice on internationalisation, but which strikes me as at odds iwth the DRY (Don’t Repeat Yourself) principle of eliminating repetitive code.

To take their example, we might have some code like this…

print 'The printer is '; if (printer.working) {     print 'on.\n'; } else {     print 'off.\n'; }  print 'The stapler is '; if (stapler.working) {     print 'on.\n'; } else {     print 'off.\n'; } 

My instinct would be to eliminate the repetition roughly as follows…

report-state(printer, 'printer'); report-state(stapler, 'stapler');  function report-state(name, object) {     print 'The '+name+' is ';     if (object.working) {         print 'on\n';     } else {         print 'off\n';     } } 

…but doing so would cause a difficulty in the code if we needed to localise it to Spanish because the word for ‘on’ is apparently different in those two cases.

So, I guess my question is, how have other developers approached balancing the DRY principle with internationalisation of their code?

Part of me wants to argue that internationalisation is one of those extreme programming “you arent gonna need it” situations. On the flip side however, refactoring with the DRY principle in mind is supposed to balance this by making it easy to implement functionality as it’s required, not harder as it does here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:04:38+00:00Added an answer on May 10, 2026 at 5:04 pm

    I’d try to keep complete sentences in the language resource. As you said you might need different words in different contexts. But a bigger problem is that the order of sentences might be different in different languages. So building up strings from words can cause problems.

    Just store

    The printer is on The printer is off The stapler is on The stapler is off 

    in the language resource for every language. The repetition here is less of a maintenance headache than trying to figure out where all the single words are going to pop up in your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 179k
  • Answers 179k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Each Service will run in it's own operating System (OS)… May 12, 2026 at 3:51 pm
  • Editorial Team
    Editorial Team added an answer My attempt at playing around with Less for .NET. May 12, 2026 at 3:51 pm
  • Editorial Team
    Editorial Team added an answer How is the user arriving at this page from the… May 12, 2026 at 3:51 pm

Related Questions

A while back I was reading the W3C article on ' Re-using Strings in
I was reading a couple of articles a while back which I think described
Do I need to learn the WCF Service trace viewer tool? I understand I
Hopefully this isn't too specific/small a question, but I was wondering if anyone knew
I'm bringing down a strongly typed dataset table into a datagridview. then adding a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.