balderdashy / balderdashy/sails

__ or i18n not available in handlebar

Open
#7,290 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**Node version**: v18.0.0
**Sails version** _(sails)_: 1.4.0
**ORM hook version** _(sails-hook-orm)_:
**Sockets hook version** _(sails-hook-sockets)_:
**Organics hook version** _(sails-hook-organics)_:
**Grunt hook version** _(sails-hook-grunt)_:
**Uploads hook version** _(sails-hook-uploads)_:
**DB adapter & version** _(e.g. sails-mysql@5.55.5)_:
**Skipper adapter & version** _(e.g. skipper-s3@5.55.5)_:


i am trying to add [i18n](https://sailsjs.com/documentation/concepts/internationalization#internationalization) in a sails app
in the sails js docs the given examples are using `i18n() or __()` inside a ejs file
but in the current project we are using handlebars and when trying to use `__()` its throwing error

```log
{"level":"error","log":{"error":{"message":"Missing helper: \"__\"","name":"Error","stack":"Error: Missing helper: \"__\"\n at Object. (node_modules/handlebars/dist/cjs/handlebars/helpers/helper-missing.js:19:13)
```

my `/config/i18n.js` looks like this:
```javascript
module.exports.i18n = {
locales: ['en', 'ur'],
defaultLocale: 'en',
localesDirectory: 'config/locales'
};
```

my `config/locales/en.json` file looks like this:
```json
{
"signup": "Create Account"
}
```

and this how i am using it in my `signup.hbs`
```html

{{{__ "signup"}}}


```

Contributor guide

Open the contributing guide

Research direction

Start with config/i18n.js, config/locales/en.json, and signup.hbs, then reproduce the Missing helper: "__" error using the reported Node and Sails versions. Trace how the Handlebars view is rendered and how i18n is exposed; done means the signup translation renders in the template or the supported usage is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
handlebars, javascript, node.js
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.