Separating Code and Text: Thinking Out Loud

The code that most of us write usually contains more text - different interface elements, descriptions, content of emails, and so on. But we programmers didn't all get A's in school for writing. We write good code, but not all of us are good at prose.





As a result, we see thousands of sites and applications that speak to users in an unnatural language, such as: “Illegal characters used” or “Operation completed successfully”. How often do you say such phrases on the street in your life? 





What if you try to separate the code (logic) and text? Large companies, for sure, have been doing this for a long time, using some of their own solutions, but for everyone else - there is no ready-made utility or framework. 





Reality

The current reality is that the programmer partly writes the texts himself (for example, the names of the buttons), partly takes the texts from the tasks. This is part of the repository - it is stored along with the code, which means that if someone in the team needs to fix something, they need to commit to the repository. Not quite perfect - this is not logic, is it just a piece of text?





@extends('layouts.main')

@section('contents')
    <h2>Welcome home</h2>

    <p>
        We are thrilled to have you back, {{ $user->first_name }}
    </p>

    <a href="{{ route('download-bitcoin') }}" class="btn btn-primary">
        Download my money
    </a>
@endsection
      
      



Problems

  • To fix the text, you need to commit to the repository with the code. For some team members (company), not programmers, this can be difficult





  • -





  •  





  • ,





- , .





  1. home.blade.php ( PHP Laravel, )





  2. , - - .





  3. , . .





  4. . - “” - , - .





Laravel, __(), , , .





( Laravel PHP).





  1. , - . , , - .





  2. , API - , . - , , . , CI/CD .





  3. , API. - , . .





  4. -, . . - . product manager, , . 









:





, , - :





@extends('layouts.main')

@section('contents')
    <h2>@lang('Welcome home')</h2>

    <p>
        @lang("We are thrilled to have you back, {$user->first_name}")
    </p>

    <a href="{{ route('download-bitcoin') }}" class="btn btn-primary">
        @lang('Download my money')
    </a>
@endsection
      
      



, , :





  1. - , open-source .





  2. - , . .





  3. The ability to implement alternative, parallel tones of voice on the site, depending on the type of user (teenager, young mother, grandfather, etc.) - you can dynamically change the communication style in the product. 





Conclusion

I would like to hear the opinions of other developers - both positive and harsh criticism. In theory, such a SaaS service could have a free open-source implementation, where the team hosts everything itself, and an optional paid service, where you can order translations, spell check, and so on.








All Articles