Doc Posted January 31, 2017 Posted January 31, 2017 Hi guys, I've just discovered (thanks to you) textdomain, which works fine. Now I'd like to use that functionality with sprintf rather than echo __("my string to translate", "my path") Is it possible ? Thanks
Martijn Geerts Posted January 31, 2017 Posted January 31, 2017 Never used it with text domains but probably something like this would work. sprintf(__('Hello %1$s how do you %2$s?', '/path/to/'), 'Doc', 'do')
Doc Posted January 31, 2017 Author Posted January 31, 2017 Thanks @Martijn Geerts It kinda works but I don't get the opportunity to translate the parameters actually. I write in my translation file '/path/to/myfile.php ' I write : __('Hello %1$s how do you %2$s?', '/path/to/'), 'Doc', 'do') but through the admin, the only sentence I see waiting for translation is : 'Hello %1$s how do you %2$s?'
Martijn Geerts Posted January 31, 2017 Posted January 31, 2017 That's correct. Doc & do are used for %1$s and %2$s. 1
Doc Posted January 31, 2017 Author Posted January 31, 2017 Yes, I understand that. But then, how can I translate the parameters too ? Do I have to do this separately ?
LostKobrakai Posted January 31, 2017 Posted January 31, 2017 Yep, you'd need to translate each string on it's own. And keep in mind that translatable strings need all to be on a separate line for parsing reasons. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now