strdup locale to avoid use-after-free

To be sure you can use the returned string encoding the currently selected locale at a later time, you must make a copy of the string. It is not guaranteed that the returned pointer remains valid over time.
From https://www.gnu.org/software/libc/manual/html_node/Setting-the-Locale.html