IfcDoc.FormEdit.EnsureLocalized C# (CSharp) Method

EnsureLocalized() private static method

Temporary routine for providing English localization for definition
private static EnsureLocalized ( DocObject def ) : void
def DocObject
return void
        private static void EnsureLocalized(DocObject def)
        {
            string locale = "en";

            DocLocalization docLocal = def.GetLocalization(locale);
            if (docLocal != null)
                return;

            docLocal = def.RegisterLocalization(locale, null, null);

            string name = def.Name;

            // strip off prefix (Ifc, Pset_, Qto_)
            if (name.StartsWith("Ifc"))
            {
                name = name.Substring(3);
            }
            else if (name.StartsWith("Pset_"))
            {
                name = name.Substring(5);
            }
            else if (name.StartsWith("Qto_"))
            {
                name = name.Substring(4);
            }

            // if all caps (e.g. enum constants), then make first capital and rest lowercase

            // insert spaces before any capitalized word
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < name.Length; i++)
            {
                char ch = name[i];

                if (Char.IsUpper(ch) && i > 0 && !Char.IsUpper(name[i - 1]))
                {
                    sb.Append(" ");
                }

                sb.Append(ch);
            }

            docLocal.Name = sb.ToString();
        }
FormEdit