X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=1c020875abd95d5e3c7cd4f90f754d4a42375241;hb=b468ccabdb13fca86ae8a324239d83490ef5832e;hp=85a04ed179e8305da1c3e4daa21e3d92fe47f949;hpb=6a516da9a403ce05b2b78b3cf1376f4dfe4be3fe;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index 85a04ed17..1c020875a 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -235,9 +235,6 @@ seconds (struct timeval t) void dvdomatic_setup () { - bindtextdomain ("libdvdomatic", LOCALE_PREFIX); - setlocale (LC_ALL, ""); - avfilter_register_all (); Format::setup_formats (); @@ -249,6 +246,50 @@ dvdomatic_setup () ui_thread = this_thread::get_id (); } +#ifdef DVDOMATIC_WINDOWS +boost::filesystem::path +mo_path () +{ + wchar_t buffer[512]; + GetModuleFileName (0, buffer, 512 * sizeof(wchar_t)); + boost::filesystem::path p (buffer); + p = p.parent_path (); + p = p.parent_path (); + p /= "locale"; + return p; +} +#endif + +void +dvdomatic_setup_i18n (string lang) +{ +#ifdef DVDOMATIC_POSIX + lang += ".UTF8"; +#endif + + if (!lang.empty ()) { + /* Override our environment language; this is essential on + Windows. + */ + char cmd[64]; + snprintf (cmd, sizeof(cmd), "LANGUAGE=%s", lang.c_str ()); + putenv (cmd); + snprintf (cmd, sizeof(cmd), "LANG=%s", lang.c_str ()); + putenv (cmd); + } + + setlocale (LC_ALL, ""); + textdomain ("libdvdomatic"); + +#ifdef DVDOMATIC_WINDOWS + bindtextdomain ("libdvdomatic", mo_path().string().c_str()); +#endif + +#ifdef DVDOMATIC_POSIX + bindtextdomain ("libdvdomatic", POSIX_LOCALE_PREFIX); +#endif +} + /** @param start Start position for the crop within the image. * @param size Size of the cropped area. * @return FFmpeg crop filter string. @@ -306,11 +347,11 @@ md5_digest (void const * data, int size) * @return MD5 digest of file's contents. */ string -md5_digest (string file) +md5_digest (boost::filesystem::path file) { - ifstream f (file.c_str(), ios::binary); + ifstream f (file.string().c_str(), ios::binary); if (!f.good ()) { - throw OpenFileError (file); + throw OpenFileError (file.string()); } f.seekg (0, ios::end); @@ -837,19 +878,6 @@ video_frames_to_audio_frames (SourceFrame v, float audio_sample_rate, float fram return ((int64_t) v * audio_sample_rate / frames_per_second); } -/** @param f Filename. - * @return true if this file is a still image, false if it is something else. - */ -bool -still_image_file (string f) -{ - string ext = boost::filesystem::path(f).extension().string(); - - transform (ext.begin(), ext.end(), ext.begin(), ::tolower); - - return (ext == N_(".tif") || ext == N_(".tiff") || ext == N_(".jpg") || ext == N_(".jpeg") || ext == N_(".png") || ext == N_(".bmp")); -} - /** @return A pair containing CPU model name and the number of processors */ pair cpu_info () @@ -885,12 +913,12 @@ audio_channel_name (int c) enhancement channel (sub-woofer)./ */ string const channels[] = { - "Left", - "Right", - "Centre", - "Lfe (sub)", - "Left surround", - "Right surround", + _("Left"), + _("Right"), + _("Centre"), + _("Lfe (sub)"), + _("Left surround"), + _("Right surround"), }; return channels[c]; @@ -960,4 +988,19 @@ FrameRateConversion::FrameRateConversion (float source, int dcp) } change_speed = !about_equal (source * factor(), dcp); + + if (!skip && !repeat && !change_speed) { + description = _("DCP and source have the same rate.\n"); + } else { + if (skip) { + description = _("DCP will use every other frame of the source.\n"); + } else if (repeat) { + description = _("Each source frame will be doubled in the DCP.\n"); + } + + if (change_speed) { + float const pc = dcp * 100 / (source * factor()); + description += String::compose (_("DCP will run at %1%% of the source speed."), pc); + } + } }