Format date in full month name in Arabic

Format dates in full month format: [Month Name] [YEAR] I use:

format(Sys.Date(),"%B %Y")

Now I would do the same, but in Arabic:

## save locals
loc <- Sys.getlocale("LC_TIME")
Sys.setlocale("LC_TIME","Arabic")
format(Sys.Date(),"%B %Y")
## "????? 2015"          ## <----should have "جويلية 2015"
## restore locales
Sys.setlocale("LC_TIME",loc)

The Arab months are not replaced by the words "????". I do not think this is a print / Unicode issue, since Arabic is displayed correctly in the console:

"مرحبا "
[1] "مرحبا "

Invoked internally strptimefor formatting, from ?strptime:

Local conversions to and from character strings are used where appropriate and available

I think that strptimedoes not have the correct translation in Arabic. If so, where can I contribute to fix this?

change

AS . , /. , Ubuntu, -pack-ar

Sys.setlocale("LC_TIME", "ar_AE.utf8"); 
format(Sys.Date(),"%B %Y") 
[1] "يوليو 2015" 

.

Windows, ( → ..) .

+4
1

. , @RichieCotton

get_today_windows <- function(locale = NULL, fmt = "%B %Y")
{
  if(!is.null(locale))
  {
    lc_ctype <- Sys.getlocale("LC_CTYPE")
    lc_time <- Sys.getlocale("LC_TIME")
    on.exit(Sys.setlocale("LC_CTYPE", lc_ctype))
    on.exit(Sys.setlocale("LC_TIME", lc_time), add = TRUE)
    Sys.setlocale("LC_CTYPE", locale)
    Sys.setlocale("LC_TIME", locale)
  }
  ## here I am changing 
  today <- format(Sys.Date(), format = fmt )
  current_codepage <- as.character(l10n_info()$codepage)
  iconv(today, from = current_codepage, to = "utf8")
}

, :

get_today_windows("Arabic_Qatar")
## [1] "يوليو 2015"

get_today_windows("Arabic_Tunisia")
## [1] "جوييه 2015"

get_today_windows("Arabic_Saudi Arabia.1256")
## [1] "يوليو 2015"
+3

All Articles