globalizejs / globalizejs/globalize

Feature suggestion: psuedolocalisation injection

Open
#769 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.8k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

I am thinking of writing a feature that would allow me to pass in a function to use on any string to pseudolocalize it (probably using /bunkat/pseudoloc), and then would (handwave) wrap the messageFormat functions for one or more locales in this function before returning them (maybe here https://github.com/globalizejs/globalize/blob/master/src/message/formatter-runtime-bind.js#L38)

Use case: I want to generate pseudoloc files on build and be able to just switch to a language I don't expect to support (e.g mongolian) to see my app in pseudo. Before I start working on this, I thought I'd check
a) is this achievable today without changing the library?
b) are there similar/different existing plans to enable pseudoloc?

**my planned functionality**
setup will add this call:
```
Globalize.pseudo.wrapper = function(inputStr) "[%%" + inputStr + "&&]"
Globalize.pseudo.locale = mn_MN
```

messages..js will return
```
Globalize.pseudo.wrapper = function(inputStr) "[%%" + inputStr + "&&]"
Globalize.b588885275 = messageFormatterFn((function( ) {
return function (d) { return pseudo.wrapper("Hello, " + d.name;) }
})(), Globalize("en").pluralGenerator({}));
```

so in my code I will have
```
function Hello = Globalize.messageFormatter("Hello")
Hello( {name: Joe} ) = "[%%Hello, Joe&&]"
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.