Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(l10n): update l10n readme #3686

Conversation

skjnldsv
Copy link
Contributor

@skjnldsv skjnldsv commented Jan 27, 2023

Readme update:


Translations

This library uses translated strings.
When you edit/create a translated string, you need to run npm run l10n:extract to update the source files.
Our awesome translation community will then be notified and a bot will sync those changes automatically.

Nonetheless, it requires a bit of caution.
When you implement a translated string, import the translate or translatePlural and add it in your methods like so:

<template>
	<element>
 		{{ t('Choose') }} 
	</element>
</template>

<script>
import { translate as t } from '@nextcloud/l10n'

export default {
	methods: {
		t,
	},
}
</script>

Please note that using a translated string as an attribute will NOT work.
But it will work if it's within an element (like the example above)

<template>
	<element :prop="t('This will not work')" />
</template>

You will instead have to define the string in the data section and use the relevant variable reference.

<template>
	<element :prop="chooseProp" />
</template>

<script>
export default {
	data() {
		return {
			chooseProp: t('Choose'),
		},
	}
}
</script>

Signed-off-by: John Molakvoæ <[email protected]>
@skjnldsv skjnldsv added the 3. to review Waiting for reviews label Jan 27, 2023
@skjnldsv skjnldsv self-assigned this Jan 27, 2023
@skjnldsv skjnldsv merged commit 58b5c43 into master Jan 27, 2023
@skjnldsv skjnldsv deleted the skjnldsv-is-updating-the-readme-for-l10n-guidelines-hello-christoph-saucisse branch January 27, 2023 12:14
@Pytal Pytal mentioned this pull request Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants