Change text domain

Hi there,

I’m new using Sage and I would like to know if there is any way to change the text-domain automatically.

text domain is ‘sage’ and I want to call it as my template name

<?php _e('Sorry, but the page you were trying to view does not exist.', 'sage'); ?>
to
<?php _e('Sorry, but the page you were trying to view does not exist.', 'my-template-name'); ?>

I could do a find-replace but I wonder if theres any way to do it automatically.

I’d apreciate any help.

Thank you

2 Likes

No it’s not possible automatically.

Given that the namespace’s name has zero effect on the functionality, it’s an odd request- can I ask why you want to do this?

Thanks for your response,

I know it has no effect on the functionality and it is probably a nonsense but the reason is:

WPML Plugin organize string translations by his text domain in the admin area. I just want WPML to show my theme name as domain name instead of ‘sage’. Thats all.

Cheers

5 Likes

I do agree this could be included on the generator, to be honest it makes sense.
Also could be set to the theme dir name automatically.

1 Like

Hi, I’m new to sage and can’t believe this is the case. From the wordpress theme developers handbook:

“The text domain must match the slug of the theme. If your theme’s name My Theme is defined in the style.css or it is contained in a folder called my-theme the domain name should be my-theme. The text domain name must use dashes and not underscores and be lowercase.”

https://developer.wordpress.org/themes/functionality/internationalization/

So not changing the text domain and leaving it as sage is bad practice basically.

2 Likes

This should be based on the theme’s name indeed, automatically.
Should we post a suggestion on https://github.com/roots/sage and perhaps even fix it ?

Please open an issue at https://github.com/roots/sage-installer/issues as this would not be modified in Sage itself

I don’t really see the need to open an issue for this. Most editors have a find/replace feature that’s easy enough to use (search: 'sage'), unless I’m missing something.

This only changes all strings to use your own Text Domain, but text domain recognized by translation plugins is still “sage”. An example from WPML:

Update: indeed changing all ‘sage’ occurrences and updating/scanning the theme again, TextDomain also changed to my custom one. It seems it’s automatic, without loading textdomain via load_textdomain() or anything.