Giter VIP home page Giter VIP logo

Comments (3)

kkomelin avatar kkomelin commented on June 9, 2024 1

@runthis Not at all. Thank you for suggesting ideas and good luck with your projects!

from laravel-translatable-string-exporter.

kkomelin avatar kkomelin commented on June 9, 2024

Thank you @runthis for your feature request.

Let me address the two cases you mention one by one:

  1. I recommend wrapping a string in the translation function as early as possible, so your first example would look like this:
$words = [__('hello'), __('world')];
  1. For the second case, I would recommend using persistent strings:
{{ sprintf( __("Your name is %s and you are awesome!"), $name) }}

The comments you're proposing is nothing else than a new meta-language on top of what we already have, similar to PHP annotations, which I'm personally not a big fan of because it adds extra complexity to the language without significant benefits (IMO).

Let's ask other users of the project whether they need this feature by starting a simple voting process.
Folks, please comment with +1 if you need this feature.

from laravel-translatable-string-exporter.

runthis avatar runthis commented on June 9, 2024

Thank you for this amazing tool, it definitely helped me get up and running on a project.

Unfortunately as it progressed, I needed strings inside of methods (like if a sprintf was used) and also inside of specific database tables and columns, among other features as mentioned above, and it all be automated, so I rolled my own artisan command that takes care of blade files, and pulling info from the database by creating my db schema in a way that makes it feasible. I'll continue using your awesome tool for other projects though!

In case anyone is curious on the regex. It is not perfect by all means, but it suits my scenario.
{(?:\s+?)?{(?:\s+?)?(?:.+?)?__\((?:\s+?)?(?:'|\")(.+?)(?:'|\")(?:\s+?)?(?:\)|,)(?:.+?)?(?:\s+?)?}(?:\s+?)?}

image

The regex explained:

{                    // Opening curly brace
  (?:\s+?)?          // Optional spacing
  {                  // Opening curly brace
    (?:\s+?)?        // Optional spacing
    (?:.+?)?         // Optional function
      __\(           // Begin translation function
        (?:\s+?)?    // Optional spacing
          (?:'|\")   // Single or double quote

            (.+?)    // Actual string to capture

          (?:'|\")   // Single or double quote
        (?:\s+?)?    // Optional spacing
      (?:\)|,)       // End translation function, basically
    (?:.+?)?         // Ending optional function
    (?:\s+?)?        // Optional spacing
  }                  // Ending curly brace
  (?:\s+?)?          // Optional spacing
}                    // Ending curly brace

We can close this feature request down for now. Thanks again!

from laravel-translatable-string-exporter.

Related Issues (20)

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.