Example #1
0
 public ProjectLangEntry(Action <string, ActiveLanguage> changed, ActiveLanguage language, string content)
 {
     _changed    = changed;
     _content    = content;
     Language    = language;
     XmlLanguage = XmlLanguage.GetLanguage(language.ToCulture().IetfLanguageTag);
 }
 public Maybe <Unit> UpdateEntry(string projectName, ActiveLanguage lang, string name, string content)
 => _engine.Mutate(nameof(UpdateEntry),
                   c =>
                   from context in c
                   from project in context.Data.Projects.FirstMaybe(p => p.ProjectName == projectName)
                   from entry in project.Entries.FirstMaybe(e => e.Key == name)
                   let newEntry = entry with {
 public static void GeneratePage(Language language, string pageName, bool copyData = false)
 {
     using (var stream = new StreamWriter(language.FilePath + "\\" + pageName + ".page"))
     {
         var activePage = ActiveLanguage.FindPage(pageName);
         if (activePage == null || !copyData)
         {
             stream.Write("");
         }
         else
         {
             foreach (var e in activePage.Data)
             {
                 stream.Write(e.Key);
                 if (copyData)
                 {
                     stream.Write("|");
                     stream.Write(e.Value);
                 }
                 stream.Write('\n');
             }
         }
     }
     language.LoadPage(pageName);
 }
Example #4
0
        private static string ReturnNullEntryString(string pageName, string entry)
        {
            var page = ActiveLanguage.FindPage(DEFUALT_PAGE_NAME);

            if (page == null)
            {
                return(string.Format("Unable to find: {0} in page: {1}", entry, pageName));
            }
            return(string.Format(page.GetEntry(DEFUALT_NO_ENTRY), entry, pageName));
        }
Example #5
0
        public static string GetEntry(string pageName, string entry)
        {
            var page = ActiveLanguage.FindPage(pageName);

            if (page == null)
            {
                return(ReturnNullEntryString(pageName, entry));
            }
            var str = page.GetEntry(entry);

            if (string.IsNullOrEmpty(str))
            {
                return(ReturnNullEntryString(pageName, entry));
            }
            return(str);
        }
        private void BindActiveLanguage()
        {
            ActiveLanguage.DataSource = LanguageDataSource.LoadAll();
            ActiveLanguage.DataBind();

            // select the active
            Language activeLanguage = LanguageDataSource.GetActiveLanguage();

            if (activeLanguage != null)
            {
                ListItem item = ActiveLanguage.Items.FindByValue(activeLanguage.Id.ToString());
                if (item != null)
                {
                    item.Selected = true;
                }
            }
        }
Example #7
0
        public void UpdateEntry(string project, ActiveLanguage lang, string name, string content)
        {
            _engine.Mutate(nameof(UpdateEntry),
                           obs => obs.Select(context =>
            {
                var entry = context.Data.Projects.FirstOrDefault(p => p.ProjectName == project)?.Entries
                            .Find(le => le.Key == name);

                if (entry == null)
                {
                    return(context);
                }
                var oldContent = entry.Values.GetValueOrDefault(lang);
                var newEntry   = entry with
                {
                    Values = oldContent == null
                            ? entry.Values.Add(lang, content)
                            : entry.Values.SetItem(lang, content)
                };

                return(context.Update(new EntryChange(newEntry), context.Data.ReplaceEntry(entry, newEntry)));
            }));
        }
 public AddActiveLanguage(ActiveLanguage activeLanguage, string projectName)
 {
     ActiveLanguage = activeLanguage;
     ProjectName    = projectName;
 }
 private sealed record UpdateRequest(string EntryName, ActiveLanguage Language, string Content,
                                     string ProjectName);
Example #10
0
 public static string GetText(string textId, string defaultText = "")
 {
     return((ActiveLanguage != null) ? ActiveLanguage.GetText(textId, defaultText) : defaultText);
 }
Example #11
0
 public static bool LoadFormLanguage(Form form)
 {
     return((ActiveLanguage != null) ? ActiveLanguage.LoadFormLanguage(form) : false);
 }