From 80b87ba861708eb2366e77c044fb8e52400b2d09 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 31 Aug 2014 23:23:49 +0100 Subject: Fix i18n of strings from src/lib/po on OS X. There were two bugs; firstly, the path to the .mo files was wrong (the code assumed that OSX was like Linux). Secondly, the string passed into putenv() must not be freed by the caller (as its docs say). It appears that you get away with not doing this on Linux and Windows. --- src/lib/util.cc | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/lib') diff --git a/src/lib/util.cc b/src/lib/util.cc index d96001d13..5f1d589d6 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -397,35 +397,42 @@ mo_path () } #endif +#ifdef DCPOMATIC_OSX +boost::filesystem::path +mo_path () +{ + return "DCP-o-matic.app/Contents/Resources"; +} +#endif + void dcpomatic_setup_gettext_i18n (string lang) { -#ifdef DCPOMATIC_POSIX +#ifdef DCPOMATIC_LINUX lang += ".UTF8"; #endif if (!lang.empty ()) { - /* Override our environment language; this is essential on - Windows. + /* Override our environment language. Note that the caller must not + free the string passed into putenv(). */ - 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); - snprintf (cmd, sizeof(cmd), "LC_ALL=%s", lang.c_str ()); - putenv (cmd); + string s = String::compose ("LANGUAGE=%1", lang); + putenv (strdup (s.c_str ())); + s = String::compose ("LANG=%1", lang); + putenv (strdup (s.c_str ())); + s = String::compose ("LC_ALL=%1", lang); + putenv (strdup (s.c_str ())); } setlocale (LC_ALL, ""); textdomain ("libdcpomatic"); -#ifdef DCPOMATIC_WINDOWS +#if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX) bindtextdomain ("libdcpomatic", mo_path().string().c_str()); bind_textdomain_codeset ("libdcpomatic", "UTF8"); #endif -#ifdef DCPOMATIC_POSIX +#ifdef DCPOMATIC_LINUX bindtextdomain ("libdcpomatic", POSIX_LOCALE_PREFIX); #endif } -- cgit v1.2.3 From bbb2a4b7ccec953900d13e7bcdad229028bc7795 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 31 Aug 2014 23:42:16 +0100 Subject: Stop CPL tag being configurable and use DCP-o-matic version number instead. --- ChangeLog | 3 +++ src/lib/config.cc | 18 ++++++++---------- src/lib/config.h | 11 +++++------ src/lib/writer.cc | 5 ++++- src/wx/config_dialog.cc | 20 ++------------------ 5 files changed, 22 insertions(+), 35 deletions(-) (limited to 'src/lib') diff --git a/ChangeLog b/ChangeLog index 99558f508..c919f85b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2014-08-31 Carl Hetherington + * Remove configurable CPL and use "DCP-o-matic (version) (git)" + instead. + * Fix lack of i18n of strings from src/lib/po on OS X. * Give a hint when content and container aspect ratios are not diff --git a/src/lib/config.cc b/src/lib/config.cc index 04f28579b..67abc63c2 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -150,9 +150,12 @@ Config::read () _default_dcp_content_type = DCPContentType::from_isdcf_name (c.get ()); } - _dcp_metadata.issuer = f.optional_string_child ("DCPMetadataIssuer").get_value_or (""); - _dcp_metadata.creator = f.optional_string_child ("DCPMetadataCreator").get_value_or (""); - + if (f.optional_string_child ("DCPMetadataIssuer")) { + _dcp_issuer = f.string_child ("DCPMetadataIssuer"); + } else if (f.optional_string_child ("DCPIssuer")) { + _dcp_issuer = f.string_child ("DCPIssuer"); + } + if (version && version.get() >= 2) { _default_isdcf_metadata = ISDCFMetadata (f.node_child ("ISDCFMetadata")); } else { @@ -266,11 +269,7 @@ Config::read_old_metadata () } else if (k == "default_dcp_content_type") { _default_dcp_content_type = DCPContentType::from_isdcf_name (v); } else if (k == "dcp_metadata_issuer") { - _dcp_metadata.issuer = v; - } else if (k == "dcp_metadata_creator") { - _dcp_metadata.creator = v; - } else if (k == "dcp_metadata_issue_date") { - _dcp_metadata.issue_date = v; + _dcp_issuer = v; } _default_isdcf_metadata.read_old_metadata (k, v); @@ -363,8 +362,7 @@ Config::write () const if (_default_dcp_content_type) { root->add_child("DefaultDCPContentType")->add_child_text (_default_dcp_content_type->isdcf_name ()); } - root->add_child("DCPMetadataIssuer")->add_child_text (_dcp_metadata.issuer); - root->add_child("DCPMetadataCreator")->add_child_text (_dcp_metadata.creator); + root->add_child("DCPIssuer")->add_child_text (_dcp_issuer); _default_isdcf_metadata.as_xml (root->add_child ("ISDCFMetadata")); diff --git a/src/lib/config.h b/src/lib/config.h index aa3c06356..4f6b57f56 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -28,7 +28,6 @@ #include #include #include -#include #include "isdcf_metadata.h" #include "colour_conversion.h" #include "server.h" @@ -145,8 +144,8 @@ public: return _default_dcp_content_type; } - libdcp::XMLMetadata dcp_metadata () const { - return _dcp_metadata; + std::string dcp_issuer () const { + return _dcp_issuer; } int default_j2k_bandwidth () const { @@ -309,8 +308,8 @@ public: changed (); } - void set_dcp_metadata (libdcp::XMLMetadata m) { - _dcp_metadata = m; + void set_dcp_issuer (std::string i) { + _dcp_issuer = i; changed (); } @@ -445,7 +444,7 @@ private: Ratio const * _default_scale; Ratio const * _default_container; DCPContentType const * _default_dcp_content_type; - libdcp::XMLMetadata _dcp_metadata; + std::string _dcp_issuer; int _default_j2k_bandwidth; int _default_audio_delay; std::vector _colour_conversions; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index e8d4f90a6..dd2e98eee 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -38,6 +38,7 @@ #include "job.h" #include "cross.h" #include "md5_digester.h" +#include "version.h" #include "i18n.h" @@ -471,7 +472,9 @@ Writer::finish () _sound_asset->compute_digest (boost::bind (&Job::set_progress, job.get(), _1, false)); } - libdcp::XMLMetadata meta = Config::instance()->dcp_metadata (); + libdcp::XMLMetadata meta; + meta.issuer = Config::instance()->dcp_issuer (); + meta.creator = String::compose ("DCP-o-matic %1 %2", dcpomatic_version, dcpomatic_git_commit); meta.set_issue_date_now (); dcp.write_xml (_film->interop (), meta, _film->is_signed() ? make_signer () : shared_ptr ()); diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index a0df1a640..463b77e97 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -301,10 +301,6 @@ public: _issuer = new wxTextCtrl (panel, wxID_ANY); table->Add (_issuer, 1, wxEXPAND); - add_label_to_sizer (table, panel, _("Default creator"), true); - _creator = new wxTextCtrl (panel, wxID_ANY); - table->Add (_creator, 1, wxEXPAND); - Config* config = Config::instance (); _still_length->SetRange (1, 3600); @@ -353,10 +349,8 @@ public: _audio_delay->SetValue (config->default_audio_delay ()); _audio_delay->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DefaultsPage::audio_delay_changed, this)); - _issuer->SetValue (std_to_wx (config->dcp_metadata().issuer)); + _issuer->SetValue (std_to_wx (config->dcp_issuer ())); _issuer->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DefaultsPage::issuer_changed, this)); - _creator->SetValue (std_to_wx (config->dcp_metadata().creator)); - _creator->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DefaultsPage::creator_changed, this)); return panel; } @@ -410,16 +404,7 @@ private: void issuer_changed () { - libdcp::XMLMetadata m = Config::instance()->dcp_metadata (); - m.issuer = wx_to_std (_issuer->GetValue ()); - Config::instance()->set_dcp_metadata (m); - } - - void creator_changed () - { - libdcp::XMLMetadata m = Config::instance()->dcp_metadata (); - m.creator = wx_to_std (_creator->GetValue ()); - Config::instance()->set_dcp_metadata (m); + Config::instance()->set_dcp_issuer (wx_to_std (_issuer->GetValue ())); } wxSpinCtrl* _j2k_bandwidth; @@ -435,7 +420,6 @@ private: wxChoice* _container; wxChoice* _dcp_content_type; wxTextCtrl* _issuer; - wxTextCtrl* _creator; }; class EncodingServersPage : public wxPreferencesPage, public Page -- cgit v1.2.3