-
Notifications
You must be signed in to change notification settings - Fork 15
Added new param state to translation parses #615
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2f1cf5e
Added new param state to translation parses
renatoalmeidav 8bc7d42
enforce narrowing values to state param on translations.ts
renatoalmeidav 5b0d4af
Merge branch 'master' into poc/l10n-bypass
daniyelnnr 1d91bb2
release beta version
daniyelnnr fa4c065
Changed early return order to better execution on handleSingleString …
renatoalmeidav 57c634f
Release v7.2.6
daniyelnnr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,63 +4,68 @@ import { MessagesLoaderV2 } from '../schema/messagesLoaderV2' | |||||
|
|
||||||
| export const CONTEXT_REGEX = /\(\(\((?<context>(.)*)\)\)\)/ | ||||||
| export const FROM_REGEX = /\<\<\<(?<from>(.)*)\>\>\>/ | ||||||
| export const CONTENT_REGEX = /\(\(\((?<context>(.)*)\)\)\)|\<\<\<(?<from>(.)*)\>\>\>/g | ||||||
| export const STATE_REGEX = /\[\[\[(?<state>(.)*)\]\]\]/ | ||||||
| export const CONTENT_REGEX = /\(\(\((?<context>(.)*)\)\)\)|\<\<\<(?<from>(.)*)\>\>\>|\[\[\[(?<state>(.)*)\]\]\]/g | ||||||
|
|
||||||
| export interface TranslatableMessageV2 { | ||||||
| from?: string | ||||||
| content: string | ||||||
| context?: string | ||||||
| state?: 'original' | 'translated' | ||||||
| } | ||||||
|
|
||||||
| export type TranslationDirectiveType = 'translatableV2' | 'translateTo' | ||||||
|
|
||||||
| export const parseTranslatableStringV2 = (rawMessage: string): TranslatableMessageV2 => { | ||||||
| const context = rawMessage.match(CONTEXT_REGEX)?.groups?.context | ||||||
| const from = rawMessage.match(FROM_REGEX)?.groups?.from | ||||||
| const state = rawMessage.match(STATE_REGEX)?.groups?.state | ||||||
| const content = rawMessage.replace(CONTENT_REGEX, '') | ||||||
|
|
||||||
| return { | ||||||
| content: content?.trim(), | ||||||
| context: context?.trim(), | ||||||
| from: from?.trim(), | ||||||
| state: (state?.trim() === 'translated' ? 'translated' : 'original') as 'translated' | 'original', | ||||||
dgenezini marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| export const formatTranslatableStringV2 = ({ from, content, context }: TranslatableMessageV2): string => | ||||||
| `${content} ${context ? `(((${context})))` : ''} ${from ? `<<<${from}>>>` : ''}` | ||||||
| export const formatTranslatableStringV2 = ({ from, content, context, state }: TranslatableMessageV2): string => | ||||||
| `${content} ${context ? `(((${context})))` : ''} ${from ? `<<<${from}>>>` : ''} ${state ? `[[[${state}]]]` : ''}` | ||||||
|
||||||
| `${content} ${context ? `(((${context})))` : ''} ${from ? `<<<${from}>>>` : ''} ${state ? `[[[${state}]]]` : ''}` | |
| `${content} ${context ? `(((${context})))` : ''} ${from ? `<<<${from}>>>` : ''} ${state === 'translated' ? `[[[${state}]]]` : ''}` |
renatoalmeidav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
renatoalmeidav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
daniyelnnr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
daniyelnnr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.