ttag-org / ttag

:orange_book: simple approach for javascript localization
https://ttag.js.org/
MIT License
338 stars 41 forks source link

Support multiple ttag instances #191

Closed OrKoN closed 4 years ago

codecov[bot] commented 4 years ago

Codecov Report

Merging #191 into master will increase coverage by 0.28%. The diff coverage is 99.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
+ Coverage    97.8%   98.09%   +0.28%     
==========================================
  Files           4        4              
  Lines         502      525      +23     
  Branches       79       79              
==========================================
+ Hits          491      515      +24     
+ Misses         11       10       -1
Impacted Files Coverage Δ
src/index.js 98.94% <99.12%> (+0.74%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d259acd...e30ed3a. Read the comment docs.

AlexMost commented 4 years ago

you version is published v1.7.22, so you can try to use the separate ttag instance. Let me know if that works for you!

OrKoN commented 4 years ago

@OrKoN cool! should that work with ttag-cli already?

AlexMost commented 4 years ago

Hi @OrKoN. ttag-cli extracts translations with babel-plugin-ttag. By default it will extract t if you are using ttag import. But there exists is --discover argument (https://github.com/ttag-org/ttag-cli#update-opts-pofile-src). It will discover all t usages. Here is an example:

console.log(t`hello`)
ttag update --discover=t some.po counter.js

So, you can pass discover opts to extract translations. Will try to investigate and maybe we should add an ability to discover member expressions such as:

(req, res) => {
   req.ttag.t`hello`;
}