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

Add translation support #133

Open
bagus-repository opened this issue May 5, 2019 · 24 comments
Open

Add translation support #133

bagus-repository opened this issue May 5, 2019 · 24 comments
Labels
Enhancement 🎉 New feature or request

Comments

@bagus-repository
Copy link

bagus-repository commented May 5, 2019

Is your feature request related to a problem? Please describe.
I think if there is translation support will be great, our school society not all good in english

Describe the solution you'd like
I hope if there is a translation feature, in-system either in-database multi language content support

Describe alternatives you've considered
Or, give config to load in-system translation on installation step and leave the in-database language single language.

Additional context
Here multi languages database design proposal, using the third approach :
Multi language database design
And for the in-system localization just follow the Laravel way
Laravel Localization

I am ready for contributing on translation to Indonesia (ISO code: ID) and code or design pattern, but i am still learning laravel, however a great Open Source Application 👋

@bagus-repository bagus-repository changed the title Adding translation support Add translation support May 5, 2019
@changeweb
Copy link
Owner

@bagus-repository I prefer the Laravel Localization way. It would be great if you follow Laravel approach while contributing.

@changeweb changeweb added the Enhancement 🎉 New feature or request label May 13, 2019
@bogdantarasenkozp
Copy link

I can help with Russian language

@gerpollo2000
Copy link
Contributor

Hi, I can start to implement Laravel localization, I think the first thing to do is to extract all labels, put them on corresponding files inside resources/lang, and modify all views to consume the proper localization files. I will create first the localization for english and from there we can add any language we want, I can help with spanish.

This is a lot of work, it will take me some time to finish all by myself, I would like some one else to be able to help me with this, but for now I'll assume I'll be working alone on this. Please let me know if there are any considerations, suggestions or if I can start with this?

Thank you

@changeweb
Copy link
Owner

@gerpollo2000 it would be great and we appreciate any community help. Yes this is a lot of work. Hope we can join you whenever it is possible.

@gerpollo2000
Copy link
Contributor

gerpollo2000 commented Jul 10, 2019

I got some progress on dev branch (not pushed yet):

Screenshot preview: https://pasteboard.co/InhA6E8.png
Demo server: http://45.79.0.114/Unifiedtransform/public/home (use default test credentials for login)

I'm having some issues with strings having apostrophe (') like Mother's name, Parent's designation, etc...

Most of the work is done, just need to adjust the problematic strings and go through all pages as they were modified.
Any feedback is welcome

@bagus-repository
Copy link
Author

@gerpollo2000 thank your for making (extracting) in-system label progress, i am sorry if i can not work in this yet,
apostrophe(') can be written with \ (backslash) in a string
'failed' => 'Identitas\' tersebut tidak cocok dengan data kami.',

@floviolleau
Copy link

floviolleau commented Jul 10, 2019

Hi,

This what I started to do. I prefer of course the Laravel localization. I worked long time ago on big Symfony2 projects and we always used the way adviced by the framework.

Here are my suggestions:
Add a file for all translation views keys called views.php in resource folder:
image
And replicate in different folders for all languages. The folder MUST be iso code languages

In this views.php file this content.:

<?php
return [
    'auth' => [
        'login' => [
            'email_or_phone_number' => 'E-Mail Or Phone Number',
            'login' => 'Login',
            'password' => 'Password'
        ]
    ],
    'components' => [
        'nav_bar_top' => [
            'login' => 'Login'
        ],
    ],
    'master_home' => [
        'dashboard' => 'Dashboard',
        'manage_school' => 'Manage School'
    ],
    'school' => [
        'admin_list' => [
            'manage_school' => 'Manage School'
        ]
    ],
    'welcome' => [
        'home' => 'Home',
        'login' => 'Login',
        'subtitle' => 'Makes managing schools an amazing experience'
    ]
];

For french example:

<?php

return [

    'auth' => [
        'login' => [
            'email_or_phone_number' => 'E-Mail ou Numéro de téléphone',
            'login' => 'Connexion',
            'password' => 'Mot de passe',
        ],
    ],
    'components' => [
        'nav_bar_top' => [
            'login' => 'Connexion'
        ],
    ],
    'master_home' => [
        'dashboard' => 'Tableau de board',
        'manage_school' => 'Gérer l\'école',
    ],
    'school' => [
        'admin_list' => [
            'manage_school' => 'Gérer l\'école',
        ],
    ],
    'welcome' => [
        'home' => 'Accueil',
        'login' => 'Connexion',
        'subtitle' => 'Faire de la gestion des écoles une expérience incroyable',
    ],

];

The file name will determine how we will use it in the naming. Each time we have an array in an array for the definition of translation, we will add a "." for the usage. Nothing more to do.

Usage in templates:

  • for sections:
    @section('title', trans('views.auth.login.login'))
  • for regular text:
<div class="form-group">
    <div class="col-md-8 col-md-offset-4">
        <button type="submit" class="btn btn-primary">
            {{ __('views.auth.login.login') }}
        </button>
    </div>
</div>

To easily handle translation, I strongly suggest to add to the project this dependency https://github.com/chriskonnertz/translation-factory
Easy to install

To change the locale and see translations, change in config/app.php 'locale' => 'fr'.

At the end, it will be interesting to have a language selector or a different routes naming : https://medium.com/@gabrieladeniji/how-to-easily-set-up-multiple-languages-for-your-web-app-laravel-localization-78c991eaa42c

Hope this help

@gerpollo2000
Copy link
Contributor

Hi,

Thanks for the feedback, in summary:

  • Apostrophes were added a backslash (on phps only)
  • Instead of views.php strategy files I used the Strings as keys strategy.
  • I liked the previous strategy because I found it has 1) simpler file structure (json), 2) strings on php files remain in original english (there's no need to add/update en.json), 3) no language keys creation needed.
  • For each translation/locale a json file must be added on /resources/lang folder with its ISO code as file name.
  • To facilitate comparison when adding new elements between locales, I added the Strings in alphabetical order (hope this keeps that way)
  • According to the context where the translation was invoked (jquery, javascript, html, directives) I had to use @lang, trans(), __() and @JSON( __()) functions. The most used was @lang
  • I added translation file es-MX.json
  • I tested that all pages were working with all profiles (student, teacher, etc...) in spanish and english. Attendance and Payment history not working from menu in any language, I think I read previously this was work in development?
  • Not all is already translated, I thing like 90% was translated, but things like placeholders, messages in dataTables, profiles names (teacher, student, etc) and success/warning messages (like "Student added", "File uploaded", etc) are still pending
  • As @floviolleau mentioned it would be good to have the language selector and the translation factory, so still pending.... locale can be changed on config/app.php 'locale' => 'fr' as mentioned
  • Demo server still available for validation
  • If time allows I'll eventually continue with the pending tasks...

@changeweb I'm ready to push changes to dev branch and create Pull request but I don't have permissions, hope you can guide me on this please:

image

Thanks!

@changeweb
Copy link
Owner

changeweb commented Jul 10, 2019

@gerpollo2000 just create a Pull Request without trying to push changes to Master branch.

But ensure your code base is up to date with latest master branch before creating PR. Otherwise it may conflict with existing code.

@gerpollo2000
Copy link
Contributor

I'm stuck, this is my first contribution to Github so I'm kind of lost. I need some more guidance please:

I'm trying to push my code to 'dev_for_new_features' branch but I can't

image

I suppose I have to push my code before creating the PR right?

For checking my code is up to date with master branch I should merge master to dev branch and solve any possible conflicts, right?

@changeweb
Copy link
Owner

changeweb commented Jul 10, 2019

@gerpollo2000 follow these steps: (I guess you are working with cloned repo)

  1. Add and make Commit for the changes you made in your local repository.
  2. Compare your local repository Master branch to remote Master branch to find conflicts.
  3. Make PR to remote Master branch instead of dev_for_new_features branch. Since that branch is not currently maintained.

I suggest you to use any Git GUI like (Github Desktop, Git Kraken) for easy Git functions.

changeweb added a commit that referenced this issue Jul 11, 2019
PR for Ticket #133 Add translation support
@floviolleau
Copy link

Hi,

I'm working on translating into fr-FR and I'm wondering about some acronyms:

  • what 'AT' stands for?
  • what 'GPA' stands for?
  • what 'taka' in 'Amount (taka)' stands for?
  • what 'Srl.' stands for?

Can you explain what is a GPA system?

@changeweb
Copy link
Owner

@floviolleau AT -> attendance, GPA -> Grade Point Average, taka -> currency of Bangladesh(replace it with France currency), Srl -> Serial may be.

@floviolleau
Copy link

floviolleau commented Sep 17, 2019

Thanks!

A liitre bit more ;)

What is 'CT Full Marks', 'OB', 'SB', 'CT+Q'?

Can you please explain a bit GPA because I'm not familiar with?

Thanks

@changeweb
Copy link
Owner

CT -> Class Test, OB -> Objective (MCQ), SB -> Subjective(Written), Q -> Quiz,
GPA -> https://en.wikipedia.org/wiki/Grading_in_education

@xMasterChiefx
Copy link

Hi, i'm trying to translate to german. i'm not a programmer at all but can read through code and get the points. the information from @floviolleau and @gerpollo2000 are quite helpful, but i'm a bit lost now.

i found the path to the lang folder \Unifiedtransform\resources\lang but there is just the spanish .json file.

my testapp is running in english right now, so i just want to be sure im in the correct folder?!

@gerpollo2000
Copy link
Contributor

Hallo,

Yes, you're in the right folder, inside Unifiedtransform\resources\lang,
you need to create the folder

de_DE

and inside you need to add the same 4 php files that are inside "en"
folder, but with the corresponding german translation

Also, inside Unifiedtransform\resources\lang folder you need to create the

de_DE.json file, clone in there the es_MX.json file, replace all spasnish
translations with german ones.

Once you're done edit the config/app.php file and set the variable locale
=> 'de_DE'

Hope it works

@xMasterChiefx
Copy link

xMasterChiefx commented Feb 8, 2020

thanks @gerpollo2000 will try right now!

where is the english file located?!

@xMasterChiefx
Copy link

xMasterChiefx commented Feb 8, 2020

Trying to access array offset on value of type null (View: /path/to/home/Unifiedtransform/resources/views/components/user-profile.blade.php) (View: /path/to/home/Unifiedtransform/resources/views/components/user-profile.blade.php)

Get this error when i edit Teachers. Someone can help here?

Edit:
Guess i'm with an incompatible phpversion PHP 7.4.2 - is PHP 7.3 supported?

@esale
Copy link

esale commented Oct 20, 2020

Hi, it would be good to be able to set the language system-wide, and also to override that for each school. I suppose this would mean to set the language into some DB tables, like schools and I don't know if there is a table for global settings.

Currently, AFAIK, you have to set language on /var/www/config/app.php which is not so convenient, even less if you are using docker.

The same applies to timezone, I think.

After that, it would also be good to be able to set the language on the user profile (e.g. for some foreign teacher), and on the course (e.g.: for some foreign language course).

I'm evaluating this software for use on a school, idk if it's adecuate yet, but I'd like to thanks anyway for sharing your work.

Regards!

@changeweb
Copy link
Owner

@esale any PR is appreciated.

@asathler
Copy link

asathler commented Jan 5, 2022

@gerpollo2000 thank your for making (extracting) in-system label progress, i am sorry if i can not work in this yet, apostrophe(') can be written with \ (backslash) in a string 'failed' => 'Identitas\' tersebut tidak cocok dengan data kami.',

You can also change apostrophe (') to quotation marks ("), as like:
'failed' => "Identitas' tersebut tidak cocok dengan data kami.",

@asathler
Copy link

asathler commented Jan 5, 2022

After the first full translation, all next ones will be lot easier...

Need some help @gerpollo2000 ?

@asathler
Copy link

asathler commented Jan 5, 2022

At the end, it will be interesting to have a language selector or a different routes naming : https://medium.com/@gabrieladeniji/how-to-easily-set-up-multiple-languages-for-your-web-app-laravel-localization-78c991eaa42c

By the way,
I think I already have a code to change user settings for languages...
I'm just studying code project first before make any changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 🎉 New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants