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

Translations #21

Closed
jbrooksuk opened this issue Sep 13, 2023 · 5 comments
Closed

Translations #21

jbrooksuk opened this issue Sep 13, 2023 · 5 comments
Assignees

Comments

@jbrooksuk
Copy link
Member

We need to provide any static strings as a translation file.

I'm quite keen on the idea of this package only containing the English US translations, then having other packages which can be installed to provide additional languages. Are there any objections to this?

@alexjustesen
Copy link

What are you're thoughts on using https://crowdin.com/ to manage translations?

Really excited this project is back btw. Happy to help contribute.

@jbrooksuk
Copy link
Member Author

Yep, we previously used CrowdIn and I think we'll continue to do so.

@jbrooksuk
Copy link
Member Author

We'll also want to make sure the frontend is translated in the dashboard too.

@jbrooksuk
Copy link
Member Author

fbdf8dd

@jbrooksuk jbrooksuk self-assigned this Jan 17, 2024
@jbrooksuk
Copy link
Member Author

For my own memory, I wrote this quick Python script to pull all strings within __ and print them out in a JSON object:

import re
import os
import json

def find_translation_strings(directories, file_extensions):
    translation_strings = {}
    regex_pattern = re.compile(r"__\('(.+?)'\)")

    for directory in directories:
        for root, dirs, files in os.walk(directory):
            for file in files:
                if any(file.endswith(ext) for ext in file_extensions):
                    with open(os.path.join(root, file), 'r') as f:
                        content = f.read()
                        matches = regex_pattern.findall(content)
                        for match in matches:
                            translation_strings[match] = match

    sorted_translation_strings = dict(sorted(translation_strings.items()))
    return json.dumps(sorted_translation_strings, indent=4)

directories = ['src', 'resources/views']
file_extensions = ['.php', '.blade.php']
translation_strings = find_translation_strings(directories, file_extensions)
print(translation_strings)

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

No branches or pull requests

2 participants