Giter Club home page Giter Club logo

Comments (7)

tricoder42 avatar tricoder42 commented on May 12, 2024 1

Alright, added in latest releases:

The function is named i18nMark after all. See the docs for more info.

from js-lingui.

vitexikora avatar vitexikora commented on May 12, 2024

IMHO the method should be named most closely to what it actually does, which in this case is something like 'markForTranslation/Extraction', 'addTranslation', 'linguiString', or even 'internationalize', rather than 'noop'... Looking at this example code I would have no idea what it does. Just an opinion.

from js-lingui.

tricoder42 avatar tricoder42 commented on May 12, 2024

Yeah I have similar concern. I know this naming from Django, but there is ugettext_noop so you at least know that it's related to gettext.

It's basically i18n.t without the translation, so maybe i18n_noop, i18n_mark, i18n_add, i18n_dummy, i18n_future, i18n_lazy (it could be also considered as "lazy" translation).

From your examples I'm considering markForTranslation 🤔

from js-lingui.

vitexikora avatar vitexikora commented on May 12, 2024

May I ask, how is this feature looking? I am really looking forward to it 👍 😊

from js-lingui.

tricoder42 avatar tricoder42 commented on May 12, 2024

I was a bit busy in last few weeks, so I was happy to find at least some time to refactor cli.

However, this should be very easy, I'll take a look this week.

If you want to work on this, it's basically just:

  1. Add another node matcher, similar to this: https://github.com/lingui/js-lingui/blob/master/packages/babel-plugin-lingui-transform-js/src/index.js#L7
  2. Make sure, we replace node with source string, not i18n.t call here: https://github.com/lingui/js-lingui/blob/master/packages/babel-plugin-lingui-transform-js/src/index.js#L218

I would go with following syntax:

import { i18n_noop } from 'lingui-i18n'

const languages = {
  en: i18n_noop('English'),
  cs: i18n_noop('Czech')
}

which would be transformed to

const languages = {
  en: 'English',
  cs: 'Czech'
}

Question is, how to handle translations with variables? 🤔 Should i18n_noop support only static translations?

from js-lingui.

vitexikora avatar vitexikora commented on May 12, 2024

Thats ok, its still cool, you have time to improve this lib and push it further 👍 Doesnt have to be all at once..

Should i18n_noop support only static translations?

Given the typical usage of such function, I guess it should not be a problem. I would make it static and create an enhancement issue with a very low priority on it supporting even variables and tags. Just to keep all functions consistent, because I can imagine (in the future) people misusing this function and wondering why it doesnt work with variables.

from js-lingui.

vitexikora avatar vitexikora commented on May 12, 2024

Awesome!

from js-lingui.

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.