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

[Request] Custom translation files #56

Closed
lonnieezell opened this issue Aug 28, 2018 · 3 comments
Closed

[Request] Custom translation files #56

lonnieezell opened this issue Aug 28, 2018 · 3 comments

Comments

@lonnieezell
Copy link

First off - thanks for this. This is working very well for us!

It would be awesome to be able to tell the RRule class to use a different translation file for a specific locale. This way if we want things to be worded differently, we can simply copy the appropriate local file, make the changes, and tell the script on the fly where to find the new translation file.

This would be a huge help to me currently as I'm trying to get the results closer to what the app designer mocked up in my API.

@rlanvin
Copy link
Owner

rlanvin commented Aug 31, 2018

Hello, I think that's a good idea. I'm a bit busy at the moment but I'll try to have a look at this soon!

@rlanvin
Copy link
Owner

rlanvin commented Sep 19, 2018

@lonnieezell I did a quick test - my first idea is simply to expose the path where to find the files as a option of humanReadable. Something like this:

echo $rrule->humanReadable([
	'base_path' => __DIR__.'/custom_translations'
]);

This is easy to implement however it's a "all or nothing" option, i.e. every locale file that you doesn't exist in this custom directory will be treated as missing (it will never look into the default directory if this option is set). This means if you want to customize French and also have the default English, you have to copy both fr.php and en.php into your custom directory.

Another approach would be to provide a map for each file, something like:

echo $rrule->humanReadable([
	'file_paths' => ['fr' => __DIR__.'/custom_translations/']
]);

Then it would only look into your custom directory if it wants to load the file for French translations (fr.php), but look into the default directory for anything else.

The two options are not mutually exclusive and if necessary I guess I could implement both.

Since you are the one with an actual use case for this feature, what's your opinion?

@lonnieezell
Copy link
Author

Thanks for looking into this!

I don't personally have any need for location at this time. However, the first option seems the easiest to use from a developer's perspective. Could you combine the two options? Like in the first one, pass in a custom directory path for any new files, but merge that with the existing one so that it has a fallback directory? The only problem there is knowing what language the directory is supposed to be for, so maybe something like:

echo $rrule->humanReadable([
	'en' => __DIR__.'/custom_translations'
]);

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