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

how to translate a form with parler_tags. #343

Open
Debbiepimpo opened this issue Sep 29, 2023 · 0 comments
Open

how to translate a form with parler_tags. #343

Debbiepimpo opened this issue Sep 29, 2023 · 0 comments

Comments

@Debbiepimpo
Copy link

Debbiepimpo commented Sep 29, 2023

Hi,
I'm trying to use the parler_tags to translate a form created in a forms.py file and pass to the html with this tag: {% form %}.

I have a navbar created with the objectlanguage tag for each language and i want to "translate" not just the name of thhe fields, i want to get translations for values into the form for each language.
Captura de pantalla 2023-09-28 114139

As you can see at this pic above, the french tag is selected but the values into the inputs are still in english.

<div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">{% translate 'Product details' %}</h3>
                </div>
                <div class="card-body">
                <div class="panel panel-primary">
                    <div class="tab-menu-heading tab-menu-heading-boxed">
                        <div class="tabs-menu-boxed">
                            <!-- Tabs -->
                            <ul class="nav panel-tabs" id="myTab" role="tablist">
                                 {% for code, title in languages %}
                                    <li class="nav-item" role="presentation">
                                        <a href="#{{ code }}-tab-pane"
                                           class="nav-link {% if code == current_language %}active{% endif %}"
                                           id="{{ code }}-tab"
                                           data-bs-toggle="tab"
                                           role="tab"
                                           aria-controls="{{ code }}-tab-pane"
                                           aria-selected="{% if code == current_language %}true{% else %}false{% endif %}">
                                            {{ title }}
                                        </a>
                                    </li>
                                 {% endfor %}
                            </ul>
                        </div>
                    </div>
                    <div class="panel-body tabs-menu-body">
                        <div class="tab-content">
                             {% for code, _ in languages %}
                                <div class="tab-pane {% if code == current_language %}active{% endif %}" id="{{ code }}-tab-pane" role="tabpanel" aria-labelledby="{{ code }}-tab">
                                    {% objectlanguage product code %}
                                    <form method="post" action="{% url 'products.edit' object.pk %}">
                                        {% csrf_token %}
                                        {% crispy form %}
                                    </form>
                                    {% endobjectlanguage %}
                                </div>
                             {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
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

1 participant