Skip to content

Conversation

dhalsim
Copy link
Contributor

@dhalsim dhalsim commented Jun 26, 2025

I'm planning to use wnj on a local website and we target only one language.

I moved all the user facing text into a JSON. And the website owner can copy texts.json, translate the values and inject them to localize wnj:

window.wnjParams = {
    texts: {
        'Create a Nostr account': 'Yeni Nostr Hesabı Oluştur',
        'Connect with Nostr': "Nostr ile Bağlan",
        ....
    }
}

t helper function is used through the code, which has a fallback to return the key if it is not found with a console.warn message that the key is missing.

Another option would be doing the translations in the wnj project. Putting a bunch of translations in the project and provide ability to set the language through wnjParams and/or from the UI. But this approach solves my problem right now.

@fiatjaf
Copy link
Owner

fiatjaf commented Jun 26, 2025

Damn, I hate translations, but this one is not as bad because it doesn't require me to keep track of translations myself.

@dhalsim
Copy link
Contributor Author

dhalsim commented Jun 26, 2025

Great! Let's wait until I test this thoroughly. There is a bug that tags are not rendered correctly right now.

compactMode: win.wnjParams?.compactMode
compactMode: win.wnjParams?.compactMode,
texts: win.wnjParams?.texts || defaultTexts,
nstartMeLanguage: win.wnjParams?.nstartMeLanguage || 'en'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ability to set a language to nstart.me link, what do you think @fiatjaf ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants