question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Contexts proposal

See original GitHub issue

One of the main feature request from other people, who sees c-3po is the context feature. Context allows us to translate the same word (the same msgid) differently, depending on the context.

For C, C++ there are separate functions for applying context to the translation: pgettext, npgettext (for single and plural forms accordingly)

pgettext(<context>, <msgid>);
pngettext(<context>, <single form>, <plural form>, <count>);

As for me I don’t like the idea of having separate functions for that. As it was designed for C initially, they almost had no other option. But we can make it better, so I would like to implement succinct API for the c-3po.

Proposal 1

To introduce special c function, that will return an object with all c-3po functions with applied context. It will accept context value as a first argument.

import { c, t } from 'c-3po'
c('context').t`Hello ${ user.name }`

// maybe better to place it on a separate lines
c('context')
.t`Hello ${ user.name}`
import { ngettext, msgid, c } from 'c-3po'
c('context').ngettext(msgid`${ n } banana`, `${ n } bananas`, n);

One thing that I am worried about, is that syntax becomes a little bit overloaded. But in general, I think context is not so frequent case. And with this apporach, it is clear how to introduce some other concepts like domains by just chaining them one after another.

d('domain')
.c('context')
.t`translate me`

Proposal 2

Place context information right into the t function call;

import { t } from 'c-3po'
t('context')`Hello ${ user.name}`
import { ngettext, msgid } from 'c-3po'
ngettext('context')(msgid`${ n } banana`, `${ n } bananas`, n);

This one looks a little bit cleaner that Proposal 1, but the question is how do we extend this to have domain info? Maybe something like this will work:

t({context: 'context', domain: 'domain'})`Hello ${ user.name}`

What do you think @MrOrz @alxpy @Suhoy95

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexMostcommented, Nov 6, 2017

available in 0.7.0 version. doc - https://c-3po.js.org/contexts.html

0reactions
AlexMostcommented, Nov 3, 2017

ready in 0.7.0-release branch. Will be available soon in 0.7.0-beta, stay tuned 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Write a Project Proposal
Context. 2.Problem. 3.Related work. 4.Solution (with desiderata (“desired things”)). 5.Aims and objectives.
Read more >
Writing the Project Context: A Sample Proposal
The project context of any proposal not only gives an introduction to your project but it also builds up a justification process.
Read more >
Author Guide - Contexts
Contexts is a quarterly magazine that makes cutting-edge social research accessible to general ... proposal and development process for feature articles:.
Read more >
proposal – contexts and usage examples in English with ...
contexts with the word "proposal" in English with translation into French by PROMT, back proposal, commission proposal, council proposal, set expressions ...
Read more >
Proposal context | MindMeister Mind Map
Proposal context. Other · AD · Ashleigh Daniels · Follow. Plan your projects and define important tasks and actions. Get Started. It's Free....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found